Skip to content

Commit 26a9149

Browse files
committed
fix(dlx): use binary name if package name doesn't match
1 parent e81dc0d commit 26a9149

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

.github/workflows/e2e-vue-cli-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ jobs:
3333
3434
echo '{"useTaobaoRegistry": false}' | tee ~/.vuerc
3535
36-
yarn dlx -p @vue/cli vue create -d my-vue && cd my-vue
36+
yarn dlx @vue/cli create -d my-vue && cd my-vue
3737
yarn build

.yarn/versions/0ae1c66a.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/plugin-dlx": patch
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-essentials"
9+
- "@yarnpkg/plugin-init"
10+
- "@yarnpkg/plugin-interactive-tools"
11+
- "@yarnpkg/plugin-node-modules"
12+
- "@yarnpkg/plugin-npm-cli"
13+
- "@yarnpkg/plugin-pack"
14+
- "@yarnpkg/plugin-patch"
15+
- "@yarnpkg/plugin-pnp"
16+
- "@yarnpkg/plugin-stage"
17+
- "@yarnpkg/plugin-typescript"
18+
- "@yarnpkg/plugin-version"
19+
- "@yarnpkg/plugin-workspace-tools"
20+
- "@yarnpkg/builder"
21+
- "@yarnpkg/core"
22+
- "@yarnpkg/doctor"

packages/plugin-dlx/sources/commands/dlx.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export default class DlxCommand extends BaseCommand {
9696

9797
const pkgs = this.packages ?? [this.command];
9898

99-
const command = structUtils.parseDescriptor(this.command).name;
99+
let command = structUtils.parseDescriptor(this.command).name;
100100

101101
const addExitCode = await this.cli.run([`add`, `--`, ...pkgs], {cwd: tmpDir, quiet: this.quiet});
102102
if (addExitCode !== 0)
@@ -113,7 +113,13 @@ export default class DlxCommand extends BaseCommand {
113113

114114
await project.restoreInstallState();
115115

116+
const binaries = await scriptUtils.getWorkspaceAccessibleBinaries(workspace);
117+
118+
if (binaries.has(command) === false && binaries.size === 1 && typeof this.packages === `undefined`)
119+
command = Array.from(binaries)[0][0];
120+
116121
return await scriptUtils.executeWorkspaceAccessibleBinary(workspace, command, this.args, {
122+
packageAccessibleBinaries: binaries,
117123
cwd: this.context.cwd,
118124
stdin: this.context.stdin,
119125
stdout: this.context.stdout,

0 commit comments

Comments
 (0)