File tree Expand file tree Collapse file tree 6 files changed +23
-22
lines changed
Expand file tree Collapse file tree 6 files changed +23
-22
lines changed Original file line number Diff line number Diff line change 66
77'use strict' ;
88
9- const Command = require ( 'commander' ) . Command ;
9+ const { Command} = require ( 'commander' ) ;
1010
1111const gitBranchIs = require ( '..' ) ;
1212const packageJson = require ( '../package.json' ) ;
Original file line number Diff line number Diff line change 55
66'use strict' ;
77
8- const execFile = require ( 'child_process' ) . execFile ;
8+ const { execFile} = require ( 'child_process' ) ;
99
1010/** Options for {@link gitBranchIs}.
1111 *
Original file line number Diff line number Diff line change 55
66'use strict' ;
77
8- const execFile = require ( 'child_process' ) . execFile ;
8+ const { execFile} = require ( 'child_process' ) ;
99const pify = require ( 'pify' ) ;
1010
1111const execFileP = pify ( execFile , { multiArgs : true } ) ;
1212
1313/**
1414 * Run git with given arguments and options.
15+ * @param {...string } args Arguments to pass to git. Last argument may be an
16+ * options object.
1517 * @return {Promise } Promise with the process output or Error for non-0 exit.
1618 */
17- function git ( /* [args ...], [options] */ ) {
19+ function git ( ...args ) {
1820 // Default to redirecting stdin (to prevent unexpected prompts) and
1921 // including any output with test output
2022 const defaultStdio = [ 'ignore' , process . stdout , process . stderr ] ;
2123
22- let args , options ;
23- if ( typeof arguments [ arguments . length - 1 ] === 'object' ) {
24- args = Array . prototype . slice . call ( arguments ) ;
24+ let options ;
25+ if ( typeof args [ args . length - 1 ] === 'object' ) {
2526 options = args . pop ( ) ;
2627 options . stdio = options . stdio || defaultStdio ;
2728 } else {
28- // Note: execFile/spawn requires Array type for arguments
29- args = Array . prototype . slice . call ( arguments ) ;
3029 options = {
3130 stdio : defaultStdio
3231 } ;
Original file line number Diff line number Diff line change 77
88
99const assert = require ( 'assert' ) ;
10- const execFile = require ( 'child_process' ) . execFile ;
10+ const { execFile} = require ( 'child_process' ) ;
1111const path = require ( 'path' ) ;
1212
1313const assertMatch = require ( '../test-lib/assert-match' ) ;
@@ -18,9 +18,7 @@ const gitBranchIsCmd = require('../bin/git-branch-is');
1818const ARGS = [ process . argv [ 0 ] , 'git-branch-is' ] ;
1919
2020// Local copy of shared constants
21- const BRANCH_CURRENT = constants . BRANCH_CURRENT ;
22- const SUBDIR_NAME = constants . SUBDIR_NAME ;
23- const TEST_REPO_PATH = constants . TEST_REPO_PATH ;
21+ const { BRANCH_CURRENT , SUBDIR_NAME , TEST_REPO_PATH } = constants ;
2422
2523const BRANCH_CURRENT_RE = new RegExp ( `\\b${ constants . BRANCH_CURRENT } \\b` ) ;
2624
Original file line number Diff line number Diff line change @@ -14,11 +14,13 @@ const assertMatch = require('../test-lib/assert-match');
1414const constants = require ( '../test-lib/constants' ) ;
1515
1616// Local copy of shared constants
17- const BRANCH_CURRENT = constants . BRANCH_CURRENT ;
18- const BRANCH_NON_EXISTENT = constants . BRANCH_NON_EXISTENT ;
19- const BRANCH_SAME_COMMIT = constants . BRANCH_SAME_COMMIT ;
20- const SUBDIR_NAME = constants . SUBDIR_NAME ;
21- const TEST_REPO_PATH = constants . TEST_REPO_PATH ;
17+ const {
18+ BRANCH_CURRENT ,
19+ BRANCH_NON_EXISTENT ,
20+ BRANCH_SAME_COMMIT ,
21+ SUBDIR_NAME ,
22+ TEST_REPO_PATH
23+ } = constants ;
2224
2325describe ( 'gitBranchIs' , ( ) => {
2426 it ( 'callback true for current branch name' , ( done ) => {
Original file line number Diff line number Diff line change @@ -17,10 +17,12 @@ const fsP = pify(fs);
1717const rimrafP = pify ( rimraf ) ;
1818
1919// Local copy of shared constants
20- const BRANCH_CURRENT = constants . BRANCH_CURRENT ;
21- const BRANCH_SAME_COMMIT = constants . BRANCH_SAME_COMMIT ;
22- const SUBDIR_NAME = constants . SUBDIR_NAME ;
23- const TEST_REPO_PATH = constants . TEST_REPO_PATH ;
20+ const {
21+ BRANCH_CURRENT ,
22+ BRANCH_SAME_COMMIT ,
23+ SUBDIR_NAME ,
24+ TEST_REPO_PATH
25+ } = constants ;
2426
2527// Global variables
2628let origCWD ;
You can’t perform that action at this time.
0 commit comments