@@ -17,41 +17,36 @@ export function createIndependentTargetCommand(
17
17
opts : AnyTarget ,
18
18
{ defaultArgs, projectCwd } : CreateIndependentCommandOptions
19
19
) {
20
- const normalizeCommand = ( {
21
- command,
22
- commands,
23
- parallel
24
- } : Partial < AnyTarget > ) : string => {
20
+ const normalizeCommand = ( ) => {
21
+ const cmd = opts . command
22
+
25
23
invariant (
26
- command ?? commands ,
24
+ cmd ?? opts . commands ,
27
25
'Either "command" or "commands" must be provided.'
28
26
)
29
27
30
- const result = Array . isArray ( command ) ? command . join ( ' ' ) : command
28
+ const result = Array . isArray ( cmd ) ? cmd . join ( ' ' ) : cmd
31
29
32
30
if ( ! result ) {
33
- const separator = parallel
31
+ const separator = opts . parallel
34
32
? TargetSeparators . PARALLEL
35
33
: TargetSeparators . NORMAL
36
34
37
- return commands ! . join ( separator )
35
+ return opts . commands ! . join ( separator )
38
36
}
39
37
40
38
return result
41
39
}
42
40
43
- const normalizeEnv = ( {
44
- env,
45
- envFile
46
- } : Partial < AnyTarget > ) : Record < string , string > | undefined => {
47
- if ( envFile ) return envfile . parse ( toAbsolutePath ( envFile ) )
41
+ const normalizeEnv = ( ) : Record < string , string > | undefined => {
42
+ if ( opts . envFile ) return envfile . parse ( toAbsolutePath ( opts . envFile ) )
48
43
if ( env ) return env
49
44
return undefined
50
45
}
51
46
52
- const command = normalizeCommand ( opts )
47
+ const command = normalizeCommand ( )
53
48
const args = compact ( [ defaultArgs , opts . args ] ) . join ( ' ' )
54
- const env = normalizeEnv ( opts )
49
+ const env = normalizeEnv ( )
55
50
const cwd = toAbsolutePath ( opts . cwd ?? projectCwd ?? process . cwd ( ) )
56
51
57
52
return {
0 commit comments