1
- /* eslint-disable no-console */
2
1
'use strict' ;
3
2
4
3
const fs = require ( 'fs' ) ;
@@ -25,7 +24,7 @@ const OMIT_FILE_RE = /^\.|\.lock|\.combyne$/;
25
24
// incorrect but still helpful assumption that no file extension means that
26
25
// something is a directory. This means Gemfile and other no-ext files are
27
26
// unnecessarily deleted, but it makes things work with minimal complexity.
28
- const PROBABLY_A_DIRECTORY_RE = / ^ [ ^ \ .] + $ / ;
27
+ const PROBABLY_A_DIRECTORY_RE = / ^ [ ^ . ] + $ / ;
29
28
30
29
// RE to match the markdown files that are extracted from the README.md
31
30
const GENERATED_MARKDOWN_RE = / ^ \d + - .* \. m d $ / ;
@@ -59,7 +58,7 @@ const promptYN = () => new Promise( ( resolve, reject ) => {
59
58
* @param {string } inputDir The file system path to the directory to read
60
59
* @returns {Promise } A promise to the string array of file names
61
60
*/
62
- const ls = ( inputDir , absolute ) => {
61
+ const ls = ( inputDir ) => {
63
62
return new Promise ( ( resolve , reject ) => {
64
63
fs . readdir ( inputDir , ( err , list ) => {
65
64
if ( err ) {
@@ -95,11 +94,11 @@ const runCommand = ( commandStr, otherArgs ) => {
95
94
stdio : 'inherit' ,
96
95
} ) ;
97
96
98
- spawnedCommand . on ( 'error' , err => {
97
+ spawnedCommand . on ( 'error' , ( err ) => {
99
98
reject ( err ) ;
100
99
} ) ;
101
100
102
- spawnedCommand . on ( 'close' , code => {
101
+ spawnedCommand . on ( 'close' , ( code ) => {
103
102
return code ? reject ( code ) : resolve ( ) ;
104
103
} ) ;
105
104
} ) ;
@@ -113,7 +112,7 @@ const runCommand = ( commandStr, otherArgs ) => {
113
112
* @returns {Promise } A promise that will resolve once all the promises
114
113
* returned by that function successfully complete
115
114
*/
116
- const runInSequence = arrOfFnsReturningPromises => {
115
+ const runInSequence = ( arrOfFnsReturningPromises ) => {
117
116
return arrOfFnsReturningPromises . reduce (
118
117
( lastStep , startNextStep ) => lastStep . then ( startNextStep ) ,
119
118
Promise . resolve ( )
@@ -132,7 +131,7 @@ runCommand( 'rm -rf docs-tmp' )
132
131
console . log ( 'By proceeding, you affirm that this is not going to ruin anybody\'s day.' ) ;
133
132
console . log ( '\nContinue?' ) ;
134
133
135
- return promptYN ( ) . then ( result => {
134
+ return promptYN ( ) . then ( ( result ) => {
136
135
if ( result ) {
137
136
console . log ( '\nGreat, let\'s get this show on the road...' ) ;
138
137
resolve ( ) ;
@@ -155,7 +154,7 @@ runCommand( 'rm -rf docs-tmp' )
155
154
// Remove auto-generated files from the root of the gh-pages branch, in case
156
155
// file names have changed since the last deploy
157
156
. then ( ( ) => ls ( projectRoot )
158
- . then ( files => {
157
+ . then ( ( files ) => {
159
158
const removeFiles = files
160
159
. filter ( file => GENERATED_MARKDOWN_RE . test ( file ) )
161
160
. map ( file => ( ) => runCommand ( `rm ${ file } ` ) ) ;
@@ -169,12 +168,12 @@ runCommand( 'rm -rf docs-tmp' )
169
168
// Filter out unneeded files from the list
170
169
. then ( fileList => fileList . filter ( result => ! OMIT_FILE_RE . test ( result ) ) )
171
170
// Copy things from the temp directory down into the directory root
172
- . then ( fileList => {
171
+ . then ( ( fileList ) => {
173
172
// Create an array of functions that each remove a directory in the root of
174
173
// this project which could block the success of the `mv` command below
175
174
const removeDirectories = fileList
176
175
. filter ( file => PROBABLY_A_DIRECTORY_RE . test ( file ) )
177
- . map ( dir => {
176
+ . map ( ( dir ) => {
178
177
// Ignore errors b/c they will usually be nothing more than a warning
179
178
// that a file we tried to delete didn't exist to begin with
180
179
return ( ) => runCommand ( `rm -rf ${ dir } ` ) . catch ( err => console . log ( err ) ) ;
@@ -183,8 +182,8 @@ runCommand( 'rm -rf docs-tmp' )
183
182
return runInSequence ( removeDirectories ) . then ( ( ) => fileList ) ;
184
183
} )
185
184
// Copy files over
186
- . then ( fileList => {
187
- const copyFiles = fileList . map ( file => {
185
+ . then ( ( fileList ) => {
186
+ const copyFiles = fileList . map ( ( file ) => {
188
187
return ( ) => runCommand ( `mv docs-tmp/${ file } ./${ file } ` ) ;
189
188
} ) ;
190
189
return runInSequence ( copyFiles ) . then ( ( ) => fileList ) ;
@@ -196,10 +195,10 @@ runCommand( 'rm -rf docs-tmp' )
196
195
// have not changed but a new .zip is generated with the same contents, Git
197
196
// will still regard it as an updated file and too many of those could bloat
198
197
// the repo. Easier to exclude it for docs-only updates.
199
- . then ( ( ) => new Promise ( ( resolve , reject ) => {
198
+ . then ( ( ) => new Promise ( ( resolve ) => {
200
199
console . log ( '\nHas the wpapi.zip bundle changed since last deploy? (If unsure, answer "Yes")' ) ;
201
200
202
- return promptYN ( ) . then ( result => {
201
+ return promptYN ( ) . then ( ( result ) => {
203
202
if ( result ) {
204
203
console . log ( 'Including updated wpapi.zip in build...' ) ;
205
204
resolve ( ) ;
@@ -215,7 +214,7 @@ runCommand( 'rm -rf docs-tmp' )
215
214
. then ( ( ) => new Promise ( ( resolve , reject ) => {
216
215
console . log ( '\nDocumentation staged for commit. Proceed with commit & push?' ) ;
217
216
218
- return promptYN ( ) . then ( result => {
217
+ return promptYN ( ) . then ( ( result ) => {
219
218
if ( result ) {
220
219
console . log ( '\nConfirmed, committing & pushing docs branch...' ) ;
221
220
resolve ( ) ;
0 commit comments