File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -105,18 +105,28 @@ async function loadWorkspace(dir: string) {
105
105
} ;
106
106
}
107
107
108
+ function fmtDate ( d : Date ) : string {
109
+ // YYMMDD-HHMMSS: 20240919-140954
110
+ const date = joinNumbers ( [ d . getFullYear ( ) , d . getMonth ( ) + 1 , d . getDate ( ) ] ) ;
111
+ const time = joinNumbers ( [ d . getHours ( ) , d . getMinutes ( ) , d . getSeconds ( ) ] ) ;
112
+ return `${ date } -${ time } ` ;
113
+ }
114
+
115
+ function joinNumbers ( items : number [ ] ) : string {
116
+ return items . map ( ( i ) => ( i + "" ) . padStart ( 2 , "0" ) ) . join ( "" ) ;
117
+ }
118
+
108
119
async function main ( ) {
109
120
const workspace = await loadWorkspace ( process . cwd ( ) ) ;
110
121
111
122
const commit = await execaCommand ( "git rev-parse --short HEAD" ) . then ( ( r ) =>
112
123
r . stdout . trim ( )
113
124
) ;
114
- const date = Math . round ( Date . now ( ) / ( 1000 * 60 ) ) ;
115
125
116
126
for ( const pkg of workspace . packages . filter ( ( p ) => ! p . data . private ) ) {
117
127
workspace . setVersion (
118
128
pkg . data . name ,
119
- `${ pkg . data . version } -${ date } .${ commit } `
129
+ `${ pkg . data . version } -${ fmtDate ( new Date ( ) ) } .${ commit } `
120
130
) ;
121
131
workspace . rename ( pkg . data . name , pkg . data . name + "-nightly" ) ;
122
132
pkg . updateDeps ( ( dep ) => {
You can’t perform that action at this time.
0 commit comments