@@ -4,19 +4,20 @@ const os = require('os')
4
4
const spawn = require ( 'cross-spawn' )
5
5
const yargsParser = require ( 'yargs-parser' )
6
6
const {
7
- hasPkgProp ,
7
+ getPkgName ,
8
8
hasFile,
9
+ hasPkgProp,
9
10
ifScript,
10
11
relative,
11
12
resolveBin,
12
- getPkgName ,
13
+ stripArgument ,
13
14
} = require ( '../utils' )
14
15
const { buildConfig} = require ( '../config/helpers/build-lint-staged' )
15
16
16
17
const hereRelative = relative ( __dirname )
17
18
18
19
const args = process . argv . slice ( 2 )
19
- const { argv : parsedArgs , aliases } = yargsParser . detailed ( args )
20
+ const { argv : parsedArgs } = yargsParser . detailed ( args )
20
21
21
22
/**
22
23
* Generate a temporary copy of the built-in lint-staged
@@ -47,15 +48,11 @@ if (parsedArgs.config && parsedArgs.testCommand) {
47
48
48
49
// Don't forward `--testCommand` or `--test-command`
49
50
// flags through to `lint-staged` (yes, this is gross)
50
- const testCommandIndex = args . findIndex (
51
- a =>
52
- a === '--testCommand' ||
53
- ( aliases . testCommand && aliases . testCommand . includes ( a . replace ( / ^ - - / , '' ) ) ) ,
51
+ const argsToForward = stripArgument (
52
+ args ,
53
+ [ '--test-command' , '--testCommand' ] ,
54
+ 2 ,
54
55
)
55
- const argsToForward = [ ...args ]
56
- if ( testCommandIndex >= 0 ) {
57
- argsToForward . splice ( testCommandIndex , 2 )
58
- }
59
56
60
57
const useCustomBuiltInConfig = ! ! parsedArgs . testCommand
61
58
const customBuiltInConfig = useCustomBuiltInConfig
0 commit comments