Skip to content

Commit 4ad5f8c

Browse files
committed
fix: independent-target-command
1 parent 4436f5b commit 4ad5f8c

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

src/commands/run/utils/independent-target-command.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,36 @@ export function createIndependentTargetCommand(
1717
opts: AnyTarget,
1818
{ defaultArgs, projectCwd }: CreateIndependentCommandOptions
1919
) {
20-
const normalizeCommand = ({
21-
command,
22-
commands,
23-
parallel
24-
}: Partial<AnyTarget>): string => {
20+
const normalizeCommand = () => {
21+
const cmd = opts.command
22+
2523
invariant(
26-
command ?? commands,
24+
cmd ?? opts.commands,
2725
'Either "command" or "commands" must be provided.'
2826
)
2927

30-
const result = Array.isArray(command) ? command.join(' ') : command
28+
const result = Array.isArray(cmd) ? cmd.join(' ') : cmd
3129

3230
if (!result) {
33-
const separator = parallel
31+
const separator = opts.parallel
3432
? TargetSeparators.PARALLEL
3533
: TargetSeparators.NORMAL
3634

37-
return commands!.join(separator)
35+
return opts.commands!.join(separator)
3836
}
3937

4038
return result
4139
}
4240

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))
4843
if (env) return env
4944
return undefined
5045
}
5146

52-
const command = normalizeCommand(opts)
47+
const command = normalizeCommand()
5348
const args = compact([defaultArgs, opts.args]).join(' ')
54-
const env = normalizeEnv(opts)
49+
const env = normalizeEnv()
5550
const cwd = toAbsolutePath(opts.cwd ?? projectCwd ?? process.cwd())
5651

5752
return {

0 commit comments

Comments
 (0)