1- /* eslint-disable no-console */
21'use strict' ;
32
43const fs = require ( 'fs' ) ;
@@ -25,7 +24,7 @@ const OMIT_FILE_RE = /^\.|\.lock|\.combyne$/;
2524// incorrect but still helpful assumption that no file extension means that
2625// something is a directory. This means Gemfile and other no-ext files are
2726// unnecessarily deleted, but it makes things work with minimal complexity.
28- const PROBABLY_A_DIRECTORY_RE = / ^ [ ^ \ .] + $ / ;
27+ const PROBABLY_A_DIRECTORY_RE = / ^ [ ^ . ] + $ / ;
2928
3029// RE to match the markdown files that are extracted from the README.md
3130const GENERATED_MARKDOWN_RE = / ^ \d + - .* \. m d $ / ;
@@ -59,7 +58,7 @@ const promptYN = () => new Promise( ( resolve, reject ) => {
5958 * @param {string } inputDir The file system path to the directory to read
6059 * @returns {Promise } A promise to the string array of file names
6160 */
62- const ls = ( inputDir , absolute ) => {
61+ const ls = ( inputDir ) => {
6362 return new Promise ( ( resolve , reject ) => {
6463 fs . readdir ( inputDir , ( err , list ) => {
6564 if ( err ) {
@@ -95,11 +94,11 @@ const runCommand = ( commandStr, otherArgs ) => {
9594 stdio : 'inherit' ,
9695 } ) ;
9796
98- spawnedCommand . on ( 'error' , err => {
97+ spawnedCommand . on ( 'error' , ( err ) => {
9998 reject ( err ) ;
10099 } ) ;
101100
102- spawnedCommand . on ( 'close' , code => {
101+ spawnedCommand . on ( 'close' , ( code ) => {
103102 return code ? reject ( code ) : resolve ( ) ;
104103 } ) ;
105104 } ) ;
@@ -113,7 +112,7 @@ const runCommand = ( commandStr, otherArgs ) => {
113112 * @returns {Promise } A promise that will resolve once all the promises
114113 * returned by that function successfully complete
115114 */
116- const runInSequence = arrOfFnsReturningPromises => {
115+ const runInSequence = ( arrOfFnsReturningPromises ) => {
117116 return arrOfFnsReturningPromises . reduce (
118117 ( lastStep , startNextStep ) => lastStep . then ( startNextStep ) ,
119118 Promise . resolve ( )
@@ -132,7 +131,7 @@ runCommand( 'rm -rf docs-tmp' )
132131 console . log ( 'By proceeding, you affirm that this is not going to ruin anybody\'s day.' ) ;
133132 console . log ( '\nContinue?' ) ;
134133
135- return promptYN ( ) . then ( result => {
134+ return promptYN ( ) . then ( ( result ) => {
136135 if ( result ) {
137136 console . log ( '\nGreat, let\'s get this show on the road...' ) ;
138137 resolve ( ) ;
@@ -155,7 +154,7 @@ runCommand( 'rm -rf docs-tmp' )
155154 // Remove auto-generated files from the root of the gh-pages branch, in case
156155 // file names have changed since the last deploy
157156 . then ( ( ) => ls ( projectRoot )
158- . then ( files => {
157+ . then ( ( files ) => {
159158 const removeFiles = files
160159 . filter ( file => GENERATED_MARKDOWN_RE . test ( file ) )
161160 . map ( file => ( ) => runCommand ( `rm ${ file } ` ) ) ;
@@ -169,12 +168,12 @@ runCommand( 'rm -rf docs-tmp' )
169168 // Filter out unneeded files from the list
170169 . then ( fileList => fileList . filter ( result => ! OMIT_FILE_RE . test ( result ) ) )
171170 // Copy things from the temp directory down into the directory root
172- . then ( fileList => {
171+ . then ( ( fileList ) => {
173172 // Create an array of functions that each remove a directory in the root of
174173 // this project which could block the success of the `mv` command below
175174 const removeDirectories = fileList
176175 . filter ( file => PROBABLY_A_DIRECTORY_RE . test ( file ) )
177- . map ( dir => {
176+ . map ( ( dir ) => {
178177 // Ignore errors b/c they will usually be nothing more than a warning
179178 // that a file we tried to delete didn't exist to begin with
180179 return ( ) => runCommand ( `rm -rf ${ dir } ` ) . catch ( err => console . log ( err ) ) ;
@@ -183,8 +182,8 @@ runCommand( 'rm -rf docs-tmp' )
183182 return runInSequence ( removeDirectories ) . then ( ( ) => fileList ) ;
184183 } )
185184 // Copy files over
186- . then ( fileList => {
187- const copyFiles = fileList . map ( file => {
185+ . then ( ( fileList ) => {
186+ const copyFiles = fileList . map ( ( file ) => {
188187 return ( ) => runCommand ( `mv docs-tmp/${ file } ./${ file } ` ) ;
189188 } ) ;
190189 return runInSequence ( copyFiles ) . then ( ( ) => fileList ) ;
@@ -196,10 +195,10 @@ runCommand( 'rm -rf docs-tmp' )
196195 // have not changed but a new .zip is generated with the same contents, Git
197196 // will still regard it as an updated file and too many of those could bloat
198197 // the repo. Easier to exclude it for docs-only updates.
199- . then ( ( ) => new Promise ( ( resolve , reject ) => {
198+ . then ( ( ) => new Promise ( ( resolve ) => {
200199 console . log ( '\nHas the wpapi.zip bundle changed since last deploy? (If unsure, answer "Yes")' ) ;
201200
202- return promptYN ( ) . then ( result => {
201+ return promptYN ( ) . then ( ( result ) => {
203202 if ( result ) {
204203 console . log ( 'Including updated wpapi.zip in build...' ) ;
205204 resolve ( ) ;
@@ -215,7 +214,7 @@ runCommand( 'rm -rf docs-tmp' )
215214 . then ( ( ) => new Promise ( ( resolve , reject ) => {
216215 console . log ( '\nDocumentation staged for commit. Proceed with commit & push?' ) ;
217216
218- return promptYN ( ) . then ( result => {
217+ return promptYN ( ) . then ( ( result ) => {
219218 if ( result ) {
220219 console . log ( '\nConfirmed, committing & pushing docs branch...' ) ;
221220 resolve ( ) ;
0 commit comments