@@ -27,11 +27,6 @@ function main(): void {
2727 // Modify the package.json structure
2828 packageJsonValue . version = nightlyVersion ;
2929
30- if ( packageJsonValue . name !== "typescript-nightly" ) {
31- packageJsonValue . name = "typescript-nightly" ;
32- packageJsonValue . keywords . push ( "nightly" , "alpha" , "beta" , "prerelease" ) ;
33- }
34-
3530 // Acquire and modify the source file that exposes the version string.
3631 const tsFilePath = ts . normalizePath ( sys . args [ 1 ] ) ;
3732 const tsFileContents = sys . readFile ( tsFilePath ) ;
@@ -40,7 +35,16 @@ function main(): void {
4035
4136 // Ensure we are actually changing something - the user probably wants to know that the update failed.
4237 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" ;
4448 }
4549
4650 // Finally write the changes to disk.
@@ -51,19 +55,19 @@ function main(): void {
5155function getNightlyVersionString ( versionString : string ) : string {
5256 // If the version string already contains "-nightly",
5357 // then get the base string and update based on that.
54- const dashNightlyPos = versionString . indexOf ( "-nightly " ) ;
58+ const dashNightlyPos = versionString . indexOf ( "-dev " ) ;
5559 if ( dashNightlyPos >= 0 ) {
5660 versionString = versionString . slice ( 0 , dashNightlyPos ) ;
5761 }
5862
5963 // We're going to append a representation of the current time at the end of the current version.
6064 // 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.
6367 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 ) ;
6569
66- return `${ versionString } -nightly- ${ timeStr } ` ;
70+ return `${ versionString } -dev. ${ timeStr } ` ;
6771}
6872
6973main ( ) ;
0 commit comments