@@ -4,19 +4,20 @@ const os = require('os')
44const spawn = require ( 'cross-spawn' )
55const yargsParser = require ( 'yargs-parser' )
66const {
7- hasPkgProp ,
7+ getPkgName ,
88 hasFile,
9+ hasPkgProp,
910 ifScript,
1011 relative,
1112 resolveBin,
12- getPkgName ,
13+ stripArgument ,
1314} = require ( '../utils' )
1415const { buildConfig} = require ( '../config/helpers/build-lint-staged' )
1516
1617const hereRelative = relative ( __dirname )
1718
1819const args = process . argv . slice ( 2 )
19- const { argv : parsedArgs , aliases } = yargsParser . detailed ( args )
20+ const { argv : parsedArgs } = yargsParser . detailed ( args )
2021
2122/**
2223 * Generate a temporary copy of the built-in lint-staged
@@ -47,15 +48,11 @@ if (parsedArgs.config && parsedArgs.testCommand) {
4748
4849// Don't forward `--testCommand` or `--test-command`
4950// 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 ,
5455)
55- const argsToForward = [ ...args ]
56- if ( testCommandIndex >= 0 ) {
57- argsToForward . splice ( testCommandIndex , 2 )
58- }
5956
6057const useCustomBuiltInConfig = ! ! parsedArgs . testCommand
6158const customBuiltInConfig = useCustomBuiltInConfig
0 commit comments