@@ -41,10 +41,10 @@ const OTHER_BRANCH_RE = getBranchRE(OTHER_BRANCH);
4141
4242function describeWithBranch ( branchName , repoDir ) {
4343 const branchRE = getBranchRE ( branchName ) ;
44- const repoArgs = ARGS . concat ( '-C' , repoDir ) ;
44+ const repoArgs = [ ... ARGS , '-C' , repoDir ] ;
4545
4646 it ( 'exit code 0 silently for same branch name' , ( done ) => {
47- gitBranchIsCmd ( repoArgs . concat ( branchName ) , ( err , result ) => {
47+ gitBranchIsCmd ( [ ... repoArgs , branchName ] , ( err , result ) => {
4848 assert . ifError ( err ) ;
4949 assert . strictEqual ( result . code , 0 ) ;
5050 assert ( ! result . stdout ) ;
@@ -54,7 +54,7 @@ function describeWithBranch(branchName, repoDir) {
5454 } ) ;
5555
5656 it ( 'exit code 1 with warning for different branch name' , ( done ) => {
57- gitBranchIsCmd ( repoArgs . concat ( OTHER_BRANCH ) , ( err , result ) => {
57+ gitBranchIsCmd ( [ ... repoArgs , OTHER_BRANCH ] , ( err , result ) => {
5858 assert . ifError ( err ) ;
5959 assert . strictEqual ( result . code , 1 ) ;
6060 assert ( ! result . stdout ) ;
@@ -67,7 +67,7 @@ function describeWithBranch(branchName, repoDir) {
6767 if ( branchName ) {
6868 it ( 'exit code 1 with warning for different case branch name' , ( done ) => {
6969 const branchUpper = branchName . toUpperCase ( ) ;
70- gitBranchIsCmd ( repoArgs . concat ( branchUpper ) , ( err , result ) => {
70+ gitBranchIsCmd ( [ ... repoArgs , branchUpper ] , ( err , result ) => {
7171 assert . ifError ( err ) ;
7272 assert . strictEqual ( result . code , 1 ) ;
7373 assert ( ! result . stdout ) ;
@@ -80,7 +80,7 @@ function describeWithBranch(branchName, repoDir) {
8080 }
8181
8282 it ( 'exit code 0 silently for case-insensitive branch name' , ( done ) => {
83- const args = repoArgs . concat ( '-i' , branchName . toUpperCase ( ) ) ;
83+ const args = [ ... repoArgs , '-i' , branchName . toUpperCase ( ) ] ;
8484 gitBranchIsCmd ( args , ( err , result ) => {
8585 assert . ifError ( err ) ;
8686 assert . strictEqual ( result . code , 0 ) ;
@@ -91,7 +91,7 @@ function describeWithBranch(branchName, repoDir) {
9191 } ) ;
9292
9393 it ( 'exit code 0 silently for inverted different branch name' , ( done ) => {
94- const args = repoArgs . concat ( '-I' , OTHER_BRANCH ) ;
94+ const args = [ ... repoArgs , '-I' , OTHER_BRANCH ] ;
9595 gitBranchIsCmd ( args , ( err , result ) => {
9696 assert . ifError ( err ) ;
9797 assert . strictEqual ( result . code , 0 ) ;
@@ -102,7 +102,7 @@ function describeWithBranch(branchName, repoDir) {
102102 } ) ;
103103
104104 it ( 'exit code 1 with warning for inverted same branch name' , ( done ) => {
105- const args = repoArgs . concat ( '-I' , branchName ) ;
105+ const args = [ ... repoArgs , '-I' , branchName ] ;
106106 gitBranchIsCmd ( args , ( err , result ) => {
107107 assert . ifError ( err ) ;
108108 assert . strictEqual ( result . code , 1 ) ;
@@ -113,7 +113,7 @@ function describeWithBranch(branchName, repoDir) {
113113 } ) ;
114114
115115 it ( 'exit 0 silently for matching anchored regex branch name' , ( done ) => {
116- const args = repoArgs . concat ( '-r' , `^${ branchName } $` ) ;
116+ const args = [ ... repoArgs , '-r' , `^${ branchName } $` ] ;
117117 gitBranchIsCmd ( args , ( err , result ) => {
118118 assert . ifError ( err ) ;
119119 assert . strictEqual ( result . code , 0 ) ;
@@ -124,7 +124,7 @@ function describeWithBranch(branchName, repoDir) {
124124 } ) ;
125125
126126 it ( 'exit 0 silently for matching substr regex branch name' , ( done ) => {
127- const args = repoArgs . concat ( '-r' , branchName . slice ( 1 , - 1 ) ) ;
127+ const args = [ ... repoArgs , '-r' , branchName . slice ( 1 , - 1 ) ] ;
128128 gitBranchIsCmd ( args , ( err , result ) => {
129129 assert . ifError ( err ) ;
130130 assert . strictEqual ( result . code , 0 ) ;
@@ -135,7 +135,7 @@ function describeWithBranch(branchName, repoDir) {
135135 } ) ;
136136
137137 it ( 'exit 0 silently for matching empty regex branch name' , ( done ) => {
138- const args = repoArgs . concat ( '-r' , '' ) ;
138+ const args = [ ... repoArgs , '-r' , '' ] ;
139139 gitBranchIsCmd ( args , ( err , result ) => {
140140 assert . ifError ( err ) ;
141141 assert . strictEqual ( result . code , 0 ) ;
@@ -147,7 +147,7 @@ function describeWithBranch(branchName, repoDir) {
147147
148148 it ( 'exit 0 silently for matching i regex branch name' , ( done ) => {
149149 const args =
150- repoArgs . concat ( '-i' , '-r' , `^${ branchName . toUpperCase ( ) } $` ) ;
150+ [ ... repoArgs , '-i' , '-r' , `^${ branchName . toUpperCase ( ) } $` ] ;
151151 gitBranchIsCmd ( args , ( err , result ) => {
152152 assert . ifError ( err ) ;
153153 assert . strictEqual ( result . code , 0 ) ;
@@ -158,7 +158,7 @@ function describeWithBranch(branchName, repoDir) {
158158 } ) ;
159159
160160 it ( 'exit 1 with warning for non-match regex branch name' , ( done ) => {
161- gitBranchIsCmd ( repoArgs . concat ( '-r' , OTHER_BRANCH ) , ( err , result ) => {
161+ gitBranchIsCmd ( [ ... repoArgs , '-r' , OTHER_BRANCH ] , ( err , result ) => {
162162 assert . ifError ( err ) ;
163163 assert . strictEqual ( result . code , 1 ) ;
164164 assert ( ! result . stdout ) ;
@@ -171,7 +171,7 @@ function describeWithBranch(branchName, repoDir) {
171171 if ( branchName ) {
172172 it ( 'exit 1 with warning for no-match case regex branch name' , ( done ) => {
173173 const branchUpper = branchName . toUpperCase ( ) ;
174- gitBranchIsCmd ( repoArgs . concat ( '-r' , branchUpper ) , ( err , result ) => {
174+ gitBranchIsCmd ( [ ... repoArgs , '-r' , branchUpper ] , ( err , result ) => {
175175 assert . ifError ( err ) ;
176176 assert . strictEqual ( result . code , 1 ) ;
177177 assert ( ! result . stdout ) ;
@@ -184,7 +184,7 @@ function describeWithBranch(branchName, repoDir) {
184184 }
185185
186186 it ( 'exit 0 silently for inverted not matching regex branch name' , ( done ) => {
187- const args = repoArgs . concat ( '-I' , '-r' , OTHER_BRANCH ) ;
187+ const args = [ ... repoArgs , '-I' , '-r' , OTHER_BRANCH ] ;
188188 gitBranchIsCmd ( args , ( err , result ) => {
189189 assert . ifError ( err ) ;
190190 assert . strictEqual ( result . code , 0 ) ;
@@ -195,7 +195,7 @@ function describeWithBranch(branchName, repoDir) {
195195 } ) ;
196196
197197 it ( 'exit 1 with warning for inverted match regex branch name' , ( done ) => {
198- const args = repoArgs . concat ( '-I' , '-r' , `^${ branchName } $` ) ;
198+ const args = [ ... repoArgs , '-I' , '-r' , `^${ branchName } $` ] ;
199199 gitBranchIsCmd ( args , ( err , result ) => {
200200 assert . ifError ( err ) ;
201201 assert . strictEqual ( result . code , 1 ) ;
@@ -206,7 +206,7 @@ function describeWithBranch(branchName, repoDir) {
206206 } ) ;
207207
208208 it ( 'exit code 1 silently with quiet option' , ( done ) => {
209- const args = repoArgs . concat ( '-q' , OTHER_BRANCH ) ;
209+ const args = [ ... repoArgs , '-q' , OTHER_BRANCH ] ;
210210 gitBranchIsCmd ( args , ( err , result ) => {
211211 assert . ifError ( err ) ;
212212 assert . strictEqual ( result . code , 1 ) ;
@@ -217,7 +217,7 @@ function describeWithBranch(branchName, repoDir) {
217217 } ) ;
218218
219219 it ( 'exit code 0 with message if verbose' , ( done ) => {
220- const args = repoArgs . concat ( '-v' , branchName ) ;
220+ const args = [ ... repoArgs , '-v' , branchName ] ;
221221 gitBranchIsCmd ( args , ( err , result ) => {
222222 assert . ifError ( err ) ;
223223 assert . strictEqual ( result . code , 0 ) ;
@@ -238,7 +238,7 @@ describe('git-branch-is', () => {
238238 } ) ;
239239
240240 it ( 'exit 2 with warning for invalid regex' , ( done ) => {
241- gitBranchIsCmd ( ARGS . concat ( '-r' , 'b[ad' ) , ( err , result ) => {
241+ gitBranchIsCmd ( [ ... ARGS , '-r' , 'b[ad' ] , ( err , result ) => {
242242 assert . ifError ( err ) ;
243243 assert . strictEqual ( result . code , 2 ) ;
244244 assert ( ! result . stdout ) ;
@@ -250,7 +250,7 @@ describe('git-branch-is', () => {
250250 // --quiet does not suppress notification of caller errors
251251 // If this behavior is desired, consider using repeated -q option.
252252 it ( 'exit 2 with warning for invalid regex with quiet' , ( done ) => {
253- gitBranchIsCmd ( ARGS . concat ( '-q' , '-r' , 'b[ad' ) , ( err , result ) => {
253+ gitBranchIsCmd ( [ ... ARGS , '-q' , '-r' , 'b[ad' ] , ( err , result ) => {
254254 assert . ifError ( err ) ;
255255 assert . strictEqual ( result . code , 2 ) ;
256256 assert ( ! result . stdout ) ;
@@ -261,7 +261,7 @@ describe('git-branch-is', () => {
261261
262262 // Note: This is one of the few errors that doesn't call process.exit
263263 it ( 'callback Error for multiple args' , ( done ) => {
264- gitBranchIsCmd ( ARGS . concat ( BRANCH_CURRENT , 'foo' ) , ( err , result ) => {
264+ gitBranchIsCmd ( [ ... ARGS , BRANCH_CURRENT , 'foo' ] , ( err , result ) => {
265265 assert ( err instanceof Error ) ;
266266 assertMatch ( err . message , / \b a r g u m e n t / i) ;
267267 assertMatch ( err . message , / \b u s a g e / i) ;
@@ -270,12 +270,13 @@ describe('git-branch-is', () => {
270270 } ) ;
271271
272272 it ( 'can specify an additional git argument' , ( done ) => {
273- const args = ARGS . concat (
273+ const args = [
274+ ...ARGS ,
274275 '-C' ,
275276 SUBDIR_NAME ,
276277 '--git-arg=--git-dir=../.git' ,
277278 BRANCH_CURRENT ,
278- ) ;
279+ ] ;
279280 gitBranchIsCmd ( args , ( err , result ) => {
280281 assert . ifError ( err ) ;
281282 assert . strictEqual ( result . code , 0 ) ;
@@ -286,13 +287,14 @@ describe('git-branch-is', () => {
286287 } ) ;
287288
288289 it ( 'can specify multiple additional git arguments' , ( done ) => {
289- const args = ARGS . concat (
290+ const args = [
291+ ...ARGS ,
290292 '-C' ,
291293 '..' ,
292294 '--git-arg=-C' ,
293295 `--git-arg=${ TEST_REPO_BRANCH_PATH } ` ,
294296 BRANCH_CURRENT ,
295- ) ;
297+ ] ;
296298 gitBranchIsCmd ( args , ( err , result ) => {
297299 assert . ifError ( err ) ;
298300 assert . strictEqual ( result . code , 0 ) ;
@@ -303,15 +305,16 @@ describe('git-branch-is', () => {
303305 } ) ;
304306
305307 it ( 'can specify an additional git arguments separately' , ( done ) => {
306- const args = ARGS . concat (
308+ const args = [
309+ ...ARGS ,
307310 '--git-arg' ,
308311 '-C' ,
309312 '--git-arg' ,
310313 TEST_REPO_BRANCH_PATH ,
311314 '-C' ,
312315 '..' ,
313316 BRANCH_CURRENT ,
314- ) ;
317+ ] ;
315318 gitBranchIsCmd ( args , ( err , result ) => {
316319 assert . ifError ( err ) ;
317320 assert . strictEqual ( result . code , 0 ) ;
@@ -322,13 +325,13 @@ describe('git-branch-is', () => {
322325 } ) ;
323326
324327 it ( 'gitArgs takes precedence over gitDir' , ( done ) => {
325- const args = ARGS . concat (
328+ const args = [
329+ ...ARGS ,
326330 '--git-arg' ,
327- // Note: Also tests that Commander interprets this as option argument
328331 '--git-dir=.git' ,
329332 '--git-dir=invalid' ,
330333 BRANCH_CURRENT ,
331- ) ;
334+ ] ;
332335 gitBranchIsCmd ( args , ( err , result ) => {
333336 assert . ifError ( err ) ;
334337 assert . strictEqual ( result . code , 0 ) ;
@@ -341,13 +344,14 @@ describe('git-branch-is', () => {
341344 it ( 'can specify git executable and args' , ( done ) => {
342345 // Ensure git-path is treated as being relative to -C
343346 const gitArg = path . relative ( SUBDIR_NAME , SURPRISE_BIN ) ;
344- const args = ARGS . concat (
347+ const args = [
348+ ...ARGS ,
345349 '-C' ,
346350 SUBDIR_NAME ,
347351 `--git-arg=${ gitArg } ` ,
348352 `--git-path=${ process . execPath } ` ,
349353 'surprise' ,
350- ) ;
354+ ] ;
351355 gitBranchIsCmd ( args , ( err , result ) => {
352356 assert . ifError ( err ) ;
353357 assert . strictEqual ( result . code , 0 ) ;
@@ -359,12 +363,13 @@ describe('git-branch-is', () => {
359363
360364 // Just like git -C and --git-dir
361365 it ( 'gitDir is relative to cwd' , ( done ) => {
362- const args = ARGS . concat (
366+ const args = [
367+ ...ARGS ,
363368 '-C' ,
364369 SUBDIR_NAME ,
365370 `--git-dir=${ path . join ( '..' , '.git' ) } ` ,
366371 BRANCH_CURRENT ,
367- ) ;
372+ ] ;
368373 gitBranchIsCmd ( args , ( err , result ) => {
369374 assert . ifError ( err ) ;
370375 assert . strictEqual ( result . code , 0 ) ;
@@ -377,7 +382,7 @@ describe('git-branch-is', () => {
377382 // Unlike an commands with expression arguments (e.g. find, test), follow
378383 // the convention that repeated flag arguments are ignored.
379384 it ( 'does not double-invert' , ( done ) => {
380- const args = ARGS . concat ( '-I' , '-I' , OTHER_BRANCH ) ;
385+ const args = [ ... ARGS , '-I' , '-I' , OTHER_BRANCH ] ;
381386 gitBranchIsCmd ( args , ( err , result ) => {
382387 assert . ifError ( err ) ;
383388 assert . strictEqual ( result . code , 0 ) ;
@@ -388,7 +393,7 @@ describe('git-branch-is', () => {
388393 } ) ;
389394
390395 it ( 'support --not as alias for -I' , ( done ) => {
391- const args = ARGS . concat ( '--not' , OTHER_BRANCH ) ;
396+ const args = [ ... ARGS , '--not' , OTHER_BRANCH ] ;
392397 gitBranchIsCmd ( args , ( err , result ) => {
393398 assert . ifError ( err ) ;
394399 assert . strictEqual ( result . code , 0 ) ;
@@ -400,7 +405,7 @@ describe('git-branch-is', () => {
400405
401406 // Careful that alias isn't handled differently
402407 it ( 'does not double-invert with alias' , ( done ) => {
403- const args = ARGS . concat ( '-I' , '--not' , OTHER_BRANCH ) ;
408+ const args = [ ... ARGS , '-I' , '--not' , OTHER_BRANCH ] ;
404409 gitBranchIsCmd ( args , ( err , result ) => {
405410 assert . ifError ( err ) ;
406411 assert . strictEqual ( result . code , 0 ) ;
@@ -411,7 +416,7 @@ describe('git-branch-is', () => {
411416 } ) ;
412417
413418 it ( 'returns a Promise with the result' , ( ) => {
414- const promise = gitBranchIsCmd ( ARGS . concat ( BRANCH_CURRENT ) ) ;
419+ const promise = gitBranchIsCmd ( [ ... ARGS , BRANCH_CURRENT ] ) ;
415420 assert ( promise instanceof global . Promise ) ;
416421 return promise . then ( ( result ) => {
417422 assert . strictEqual ( result . code , 0 ) ;
@@ -421,11 +426,9 @@ describe('git-branch-is', () => {
421426 } ) ;
422427
423428 it ( 'rejects the Promise with an Error' , ( ) => {
424- const promise = gitBranchIsCmd ( ARGS . concat (
425- '-C' ,
426- OTHER_BRANCH ,
427- BRANCH_CURRENT ,
428- ) ) ;
429+ const promise = gitBranchIsCmd (
430+ [ ...ARGS , '-C' , OTHER_BRANCH , BRANCH_CURRENT ] ,
431+ ) ;
429432 assert ( promise instanceof global . Promise ) ;
430433 return promise . then (
431434 ( result ) => { throw new Error ( 'expecting Error' ) ; } ,
@@ -456,9 +459,7 @@ describe('git-branch-is', () => {
456459
457460 it ( 'throws without a callback' , ( ) => {
458461 assert . throws (
459- ( ) => {
460- gitBranchIsCmd ( ARGS . concat ( BRANCH_CURRENT ) ) ;
461- } ,
462+ ( ) => gitBranchIsCmd ( [ ...ARGS , BRANCH_CURRENT ] ) ,
462463 ( err ) => err instanceof TypeError
463464 && / \b c a l l b a c k \b / . test ( err . message ) ,
464465 ) ;
0 commit comments