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(essentials): support forwarding --require in yarn run #4376

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .yarn/versions/06061960.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
releases:
"@yarnpkg/cli": minor
"@yarnpkg/plugin-essentials": minor

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
7 changes: 7 additions & 0 deletions packages/plugin-essentials/sources/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export default class RunCommand extends BaseCommand {
description: `Ignore any user defined scripts and only check for binaries`,
});

require = Option.String(`--require`, {
description: `Forwarded to the underlying Node process when executing a binary`,
});

// The v1 used to print the Yarn version header when using "yarn run", which
// was messing with the output of things like `--version` & co. We don't do
// this anymore, but many workflows use `yarn run --silent` to make sure that
Expand Down Expand Up @@ -103,6 +107,9 @@ export default class RunCommand extends BaseCommand {
}
}

if (this.require)
nodeArgs.push(`--require=${this.require}`);

return await scriptUtils.executePackageAccessibleBinary(effectiveLocator, this.scriptName, this.args, {
cwd: this.context.cwd,
project,
Expand Down