1
1
"use strict" ;
2
2
3
- const fs = require ( "fs" ) ;
3
+ const fs = require ( "node: fs" ) ;
4
4
const shell = require ( "shelljs" ) ;
5
- const path = require ( "path" ) ;
6
- const os = require ( "os" ) ;
5
+ const path = require ( "node: path" ) ;
6
+ const os = require ( "node: os" ) ;
7
7
8
8
const cdnFolderContainer = "dist/cdn" ;
9
9
const cdnFolderVersioned = `${ cdnFolderContainer } /versioned` ;
@@ -49,7 +49,7 @@ function makeReleaseCopies( Release ) {
49
49
] . forEach ( ( { filesMap, cdnFolder } ) => {
50
50
shell . mkdir ( "-p" , cdnFolder ) ;
51
51
52
- Object . keys ( filesMap ) . forEach ( key => {
52
+ Object . keys ( filesMap ) . forEach ( ( key ) => {
53
53
let text ;
54
54
const builtFile = filesMap [ key ] ;
55
55
const unpathedFile = key . replace ( / @ V E R / g, Release . newVersion ) ;
@@ -60,28 +60,33 @@ function makeReleaseCopies( Release ) {
60
60
// Map files need to reference the new uncompressed name;
61
61
// assume that all files reside in the same directory.
62
62
// "file":"jquery.min.js" ... "sources":["jquery.js"]
63
- text = fs . readFileSync ( builtFile , "utf8" )
64
- . replace ( / " f i l e " : " ( [ ^ " ] + ) " / ,
65
- "\"file\":\"" + unpathedFile . replace ( / \. m i n \. m a p / , ".min.js\"" ) )
66
- . replace ( / " s o u r c e s " : \[ " ( [ ^ " ] + ) " \] / ,
67
- "\"sources\":[\"" + unpathedFile . replace ( / \. m i n \. m a p / , ".js" ) + "\"]" ) ;
63
+ text = fs
64
+ . readFileSync ( builtFile , "utf8" )
65
+ . replace (
66
+ / " f i l e " : " ( [ ^ " ] + ) " / ,
67
+ `"file":"${ unpathedFile . replace ( / \. m i n \. m a p / , ".min.js" ) } "`
68
+ )
69
+ . replace (
70
+ / " s o u r c e s " : \[ " ( [ ^ " ] + ) " \] / ,
71
+ `"sources":["${ unpathedFile . replace ( / \. m i n \. m a p / , ".js" ) } "]`
72
+ ) ;
68
73
fs . writeFileSync ( releaseFile , text ) ;
69
74
} else if ( builtFile !== releaseFile ) {
70
75
shell . cp ( "-f" , builtFile , releaseFile ) ;
71
76
}
72
77
} ) ;
73
-
74
78
} ) ;
75
79
}
76
80
77
81
async function makeArchives ( Release ) {
78
-
79
82
Release . chdir ( Release . dir . repo ) ;
80
83
81
84
async function makeArchive ( { cdn, filesMap, cdnFolder } ) {
82
85
return new Promise ( ( resolve , reject ) => {
83
86
if ( Release . preRelease ) {
84
- console . log ( "Skipping archive creation for " + cdn + "; this is a beta release." ) ;
87
+ console . log (
88
+ `Skipping archive creation for ${ cdn } ; this is a beta release.`
89
+ ) ;
85
90
resolve ( ) ;
86
91
return ;
87
92
}
@@ -99,41 +104,45 @@ async function makeArchives( Release ) {
99
104
100
105
output . on ( "close" , resolve ) ;
101
106
102
- output . on ( "error" , err => {
107
+ output . on ( "error" , ( err ) => {
103
108
reject ( err ) ;
104
109
} ) ;
105
110
106
111
archiver . pipe ( output ) ;
107
112
108
113
let finalFilesMap = Object . create ( null ) ;
109
114
for ( const [ releaseFile , builtFile ] of Object . entries ( filesMap ) ) {
110
- finalFilesMap [ releaseFile . replace ( rver , Release . newVersion ) ] = builtFile ;
115
+ finalFilesMap [ releaseFile . replace ( rver , Release . newVersion ) ] =
116
+ builtFile ;
111
117
}
112
118
113
- const files = Object
114
- . keys ( filesMap )
115
- . map ( item => `${ cdnFolder } /${
116
- item . replace ( rver , Release . newVersion )
117
- } ` ) ;
119
+ const files = Object . keys ( filesMap ) . map (
120
+ ( item ) => `${ cdnFolder } /${ item . replace ( rver , Release . newVersion ) } `
121
+ ) ;
118
122
119
123
if ( os . platform ( ) === "win32" ) {
120
124
sum = [ ] ;
121
125
for ( i = 0 ; i < files . length ; i ++ ) {
122
126
result = Release . exec (
123
- "certutil -hashfile " + files [ i ] + " MD5" , "Error retrieving md5sum"
127
+ "certutil -hashfile " + files [ i ] + " MD5" ,
128
+ "Error retrieving md5sum"
124
129
) ;
125
130
sum . push ( rmd5 . exec ( result ) [ 0 ] + " " + files [ i ] ) ;
126
131
}
127
132
sum = sum . join ( "\n" ) ;
128
133
} else {
129
- sum = Release . exec ( "md5 -r " + files . join ( " " ) , "Error retrieving md5sum" ) ;
134
+ sum = Release . exec (
135
+ "md5 -r " + files . join ( " " ) ,
136
+ "Error retrieving md5sum"
137
+ ) ;
130
138
}
131
139
fs . writeFileSync ( md5file , sum ) ;
132
140
files . push ( md5file ) ;
133
141
134
- files . forEach ( file => {
135
- archiver . append ( fs . createReadStream ( file ) ,
136
- { name : path . basename ( file ) } ) ;
142
+ files . forEach ( ( file ) => {
143
+ archiver . append ( fs . createReadStream ( file ) , {
144
+ name : path . basename ( file )
145
+ } ) ;
137
146
} ) ;
138
147
139
148
archiver . finalize ( ) ;
0 commit comments