Skip to content

Commit c6f5242

Browse files
committed
feat: add run --global option
1 parent d1961ee commit c6f5242

File tree

16 files changed

+48
-27
lines changed

16 files changed

+48
-27
lines changed

.github/actions/prepare/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ runs:
1616
- name: 'Build the standard bundle'
1717
if: steps.cache-build.outputs.cache-hit != 'true'
1818
run: |
19-
node ./scripts/run-yarn.js build:cli
19+
node ./scripts/run-yarn.js run --global build:cli
2020
shell: bash
2121
#endregion
2222

.github/workflows/integration-workflow.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ jobs:
159159
- name: 'Build bundle & plugins'
160160
run: |
161161
node --version
162-
node ./scripts/run-yarn.js build:pnp:hook
163-
node ./scripts/run-yarn.js build:cli
162+
node ./scripts/run-yarn.js run --global build:pnp:hook
163+
node ./scripts/run-yarn.js run --global build:cli
164164
mv ./packages/yarnpkg-cli/bundles/yarn.js ./packages/yarnpkg-cli/bundles/yarn-min.js
165-
node ./scripts/run-yarn.js build:cli --no-minify
165+
node ./scripts/run-yarn.js run --global build:cli --no-minify
166166
shell: bash
167167

168168
- uses: actions/upload-artifact@v2
@@ -174,7 +174,7 @@ jobs:
174174
175175
- name: 'Build vscode-zipfs'
176176
run: |
177-
node ./scripts/run-yarn.js package:vscode-zipfs
177+
node ./scripts/run-yarn.js run --global package:vscode-zipfs
178178
if: |
179179
success() || failure()
180180

.github/workflows/package-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: 'Build the standard bundle'
2828
run: |
2929
set -ex
30-
node ./scripts/run-yarn.js build:cli
30+
node ./scripts/run-yarn.js run --global build:cli
3131
3232
- name: 'Build the dist directory'
3333
run: |

.yarn/versions/c5422023.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
releases:
2+
"@yarnpkg/plugin-essentials": major
3+
"@yarnpkg/plugin-workspace-tools": major
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-github"
8+
- "@yarnpkg/fslib"
9+
- "@yarnpkg/nm"
10+
- "@yarnpkg/parsers"
11+
- "@yarnpkg/pnpify"
12+
- "@yarnpkg/shell"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Yarn now accepts sponsorships! Please give a look at our [OpenCollective](https:
1616
- Some legacy layers have been sunset:
1717
- Plugins cannot access the Clipanion 2 APIs anymore (upgrade to [Clipanion 3](https://github.com/arcanis/clipanion))
1818
- Plugins cannot access the internal copy of Yup anymore (use [Typanion](https://github.com/arcanis/typanion) instead)
19+
- Scripts containing a colon are no longer implicitly global. The `--global` option should be used instead.
1920

2021
### **API Changes**
2122

constraints.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ gen_enforced_field(WorkspaceCwd, 'scripts.update-local', '<any value>') :-
6969
inline_compile('@yarnpkg/eslint-config').
7070
inline_compile('@yarnpkg/libui').
7171

72-
gen_enforced_field(WorkspaceCwd, 'scripts.prepack', 'run build:compile "$(pwd)"') :-
72+
gen_enforced_field(WorkspaceCwd, 'scripts.prepack', 'run --global build:compile "$(pwd)"') :-
7373
workspace(WorkspaceCwd),
7474
% This package is built using Rollup, so we allow it to configure its build scripts itself
7575
\+ workspace_ident(WorkspaceCwd, '@yarnpkg/pnp'),

packages/acceptance-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"pkg-tests-core": "workspace:^"
1414
},
1515
"scripts": {
16-
"test:integration": "run test:unit --config \"$(pwd)/jest.config.js\""
16+
"test:integration": "run --global test:unit --config \"$(pwd)/jest.config.js\""
1717
},
1818
"repository": {
1919
"type": "git",

packages/plugin-compat/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
},
3030
"scripts": {
3131
"postpack": "rm -rf lib",
32-
"prepack": "run build:compile \"$(pwd)\"",
33-
"test:plugin-compat": "run test:unit --config \"$(pwd)/jest.config.js\"",
32+
"prepack": "run --global build:compile \"$(pwd)\"",
33+
"test:plugin-compat": "run --global test:unit --config \"$(pwd)/jest.config.js\"",
3434
"debug:patch": "node -r @yarnpkg/monorepo/scripts/setup-ts-execution extra/debugPatch \"$INIT_CWD\""
3535
},
3636
"publishConfig": {

packages/plugin-essentials/sources/commands/run.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export default class RunCommand extends BaseCommand {
5656
description: `Forwarded to the underlying Node process when executing a binary`,
5757
});
5858

59+
global = Option.Boolean(`--global`, false, {
60+
description: `Check all workspaces for ones that declare the script uniquely`,
61+
});
62+
5963
// The v1 used to print the Yarn version header when using "yarn run", which
6064
// was messing with the output of things like `--version` & co. We don't do
6165
// this anymore, but many workflows use `yarn run --silent` to make sure that
@@ -123,13 +127,13 @@ export default class RunCommand extends BaseCommand {
123127

124128
// When it fails, we try to check whether it's a global script (ie we look
125129
// into all the workspaces to find one that exports this script). We only do
126-
// this if the script name contains a colon character (":"), and we skip
130+
// this if the `--global` option is passed, and we skip
127131
// this logic if multiple workspaces share the same script name.
128132
//
129133
// We also disable this logic for packages coming from third-parties (ie
130134
// not workspaces). No particular reason except maybe security concerns.
131135

132-
if (!this.topLevel && !this.binariesOnly && workspace && this.scriptName.includes(`:`)) {
136+
if (!this.topLevel && !this.binariesOnly && workspace && this.global) {
133137
const candidateWorkspaces = await Promise.all(project.workspaces.map(async workspace => {
134138
return workspace.manifest.scripts.has(this.scriptName) ? workspace : null;
135139
}));

packages/plugin-github/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"@yarnpkg/plugin-git": "workspace:^"
1717
},
1818
"scripts": {
19-
"test": "run test:unit packages/plugin-github",
19+
"test": "run --global test:unit packages/plugin-github",
2020
"postpack": "rm -rf lib",
21-
"prepack": "run build:compile \"$(pwd)\""
21+
"prepack": "run --global build:compile \"$(pwd)\""
2222
},
2323
"repository": {
2424
"type": "git",

0 commit comments

Comments
 (0)