File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
2+
3+ const json = JSON . parse ( fs . readFileSync ( "./package.json" ) . toString ( ) ) ;
4+ const stableVersion = json . version . match ( / ( \d + ) \. ( \d + ) \. ( \d + ) / ) ;
5+ const major = stableVersion [ 1 ] ;
6+ const minor = stableVersion [ 2 ] ;
7+
8+ function prependZero ( number ) {
9+ if ( number > 99 ) {
10+ throw "Unexpected value to prepend with zero" ;
11+ }
12+ return `${ number < 10 ? "0" : "" } ${ number } ` ;
13+ }
14+
15+ const date = new Date ( ) ;
16+ const month = date . getMonth ( ) + 1 ;
17+ const day = date . getDate ( ) ;
18+ const hours = date . getHours ( ) ;
19+ patch = `${ date . getFullYear ( ) } ${ prependZero ( month ) } ${ prependZero ( day ) } ${ prependZero ( hours ) } ` ;
20+
21+ const insiderPackageJson = Object . assign ( json , {
22+ version : `${ major } .${ minor } .${ patch } ` ,
23+ } ) ;
24+
25+ fs . writeFileSync ( "./package.insiders.json" , JSON . stringify ( insiderPackageJson ) ) ;
You can’t perform that action at this time.
0 commit comments