Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(exec): support shell interpreter #4328

Merged
merged 6 commits into from
Feb 13, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 19 additions & 7 deletions packages/plugin-commands-script-runners/src/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ export const shorthands = {
export const commandNames = ['exec']

export function rcOptionsTypes () {
BlackHole1 marked this conversation as resolved.
Show resolved Hide resolved
return pick([
'bail',
'sort',
'unsafe-perm',
'workspace-concurrency',
], types)
return {
...pick([
'bail',
'sort',
'unsafe-perm',
'workspace-concurrency',
], types),
'shell-mode': Boolean,
}
}

export const cliOptionsTypes = () => ({
Expand All @@ -54,11 +57,18 @@ For options that may be used with `-r`, see "pnpm help recursive"',
name: '--recursive',
shortAlias: '-r',
},
{
description: 'If exist, runs file inside of a shell. \
Uses /bin/sh on UNIX and \\cmd.exe on Windows. \
A different shell can be specified as a string. \
BlackHole1 marked this conversation as resolved.
Show resolved Hide resolved
The shell should understand the -c switch on UNIX or /d /s /c on Windows.',
BlackHole1 marked this conversation as resolved.
Show resolved Hide resolved
name: '--shell-mode',
BlackHole1 marked this conversation as resolved.
Show resolved Hide resolved
},
],
},
],
url: docsUrl('exec'),
usages: ['pnpm [-r] exec <command> [args...]'],
usages: ['pnpm [-r] [--shell-mode] exec <command> [args...]'],
})
}

Expand All @@ -70,6 +80,7 @@ export async function handler (
reverse?: boolean
sort?: boolean
workspaceConcurrency?: number
shellMode?: boolean
} & Pick<Config, 'extraBinPaths' | 'lockfileDir' | 'dir' | 'userAgent' | 'recursive' | 'workspaceDir'>,
params: string[]
) {
Expand Down Expand Up @@ -134,6 +145,7 @@ export async function handler (
cwd: prefix,
env,
stdio: 'inherit',
shell: opts.shellMode ?? false,
})
result.passes++
} catch (err: any) { // eslint-disable-line
Expand Down