@@ -27,11 +27,6 @@ function main(): void {
27
27
// Modify the package.json structure
28
28
packageJsonValue . version = nightlyVersion ;
29
29
30
- if ( packageJsonValue . name !== "typescript-nightly" ) {
31
- packageJsonValue . name = "typescript-nightly" ;
32
- packageJsonValue . keywords . push ( "nightly" , "alpha" , "beta" , "prerelease" ) ;
33
- }
34
-
35
30
// Acquire and modify the source file that exposes the version string.
36
31
const tsFilePath = ts . normalizePath ( sys . args [ 1 ] ) ;
37
32
const tsFileContents = sys . readFile ( tsFilePath ) ;
@@ -40,7 +35,16 @@ function main(): void {
40
35
41
36
// Ensure we are actually changing something - the user probably wants to know that the update failed.
42
37
if ( tsFileContents === modifiedTsFileContents ) {
43
- throw `File '${ tsFilePath } ' did not contain pattern ${ versionAssignmentRegExp } ` ;
38
+ let err = `\n '${ tsFilePath } ' was not updated while configuring for a nightly publish.\n ` ;
39
+
40
+ if ( tsFileContents . match ( versionAssignmentRegExp ) ) {
41
+ err += `Ensure that you have not already run this script; otherwise, erase your changes using 'git checkout -- "${ tsFilePath } "'.` ;
42
+ }
43
+ else {
44
+ err += `The file seems to no longer have a string matching '${ versionAssignmentRegExp } '.` ;
45
+ }
46
+
47
+ throw err + "\n" ;
44
48
}
45
49
46
50
// Finally write the changes to disk.
@@ -51,19 +55,19 @@ function main(): void {
51
55
function getNightlyVersionString ( versionString : string ) : string {
52
56
// If the version string already contains "-nightly",
53
57
// then get the base string and update based on that.
54
- const dashNightlyPos = versionString . indexOf ( "-nightly " ) ;
58
+ const dashNightlyPos = versionString . indexOf ( "-dev " ) ;
55
59
if ( dashNightlyPos >= 0 ) {
56
60
versionString = versionString . slice ( 0 , dashNightlyPos ) ;
57
61
}
58
62
59
63
// We're going to append a representation of the current time at the end of the current version.
60
64
// String.prototype.toISOString() returns a 24-character string formatted as 'YYYY-MM-DDTHH:mm:ss.sssZ',
61
- // but we'd prefer to just use hyphens as separators instead of 'T', ':', and '.' .
62
- // The trailing 'Z' in this string can be removed; UTC time will always be implicit here.
65
+ // but we'd prefer to just remove separators and limit ourselves to YYYYMMDD .
66
+ // UTC time will always be implicit here.
63
67
const now = new Date ( ) ;
64
- const timeStr = now . toISOString ( ) . slice ( 0 , - 1 ) . replace ( / : | T | \. / g, "-" ) ;
68
+ const timeStr = now . toISOString ( ) . replace ( / : | T | \. | - / g, "" ) . slice ( 0 , 8 ) ;
65
69
66
- return `${ versionString } -nightly- ${ timeStr } ` ;
70
+ return `${ versionString } -dev. ${ timeStr } ` ;
67
71
}
68
72
69
73
main ( ) ;
0 commit comments