Visitar URL original
chore(tools): don't fail `npm run new` when VS Code CLI is missing by ValentinYoushkevich · Pull Request #3116 · vuejs/eslint-plugin-vue · GitHub
Skip to content

chore(tools): don't fail npm run new when VS Code CLI is missing - #3116

Merged
FloEdelmann merged 2 commits into
vuejs:masterfrom
ValentinYoushkevich:fix/new-rule-missing-vscode-cli
Aug 12, 2026
Merged

FloEdelmann merged 2 commits into
vuejs:masterfrom
ValentinYoushkevich:fix/new-rule-missing-vscode-cli

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

Closes #2781

npm run new <rule name> <author name> writes the rule, test and docs files and then opens them with the VS Code CLI. When code is not on PATH — the contributor uses another editor, or VS Code is installed without the shell command — the first execSync throws:

/bin/sh: code: command not found
Error: Command failed: code "path/to/generated/file"
    at Object.execSync (node:child_process:954:15)
    at tools/new-rule.js:143:6

All three files are generated successfully at that point, but:

  • the remaining two files are never opened, because the first execSync throws;
  • the script exits with code 1 and a Node stack trace, so it looks like the generation itself failed;
  • the paths of the generated files are never printed, so it is not obvious what was created.

This is the first command a new contributor runs from the developer guide, so it is worth failing softly.

Changes

  • print the paths of the generated files;
  • wrap the editor launch in try/catch and ignore the failure — the files are already on disk, there is nothing to recover from.

Verification

Without code on PATH:

$ npm run new some-rule Someone
Created:
  lib/rules/some-rule.ts
  tests/lib/rules/some-rule.test.ts
  docs/rules/some-rule.md
$ echo $?
0

With code on PATH the three files are still opened as before.

No changeset: tools/ is not part of the published package ("files": ["dist"]), same as #3049

`npm run new` writes the rule, test and docs files and then opens them
with the VS Code CLI. When `code` is not on PATH - other editors, or VS
Code installed without the shell command - the first `execSync` throws,
the remaining files are never opened, and the script exits with a Node
stack trace even though all three files were generated successfully.

Print the paths of the generated files and ignore a failure to launch
the editor, so the command always ends cleanly.

Closes vuejs#2781
@changeset-bot

changeset-bot Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9293b24

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@FloEdelmann FloEdelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, thank you!

@FloEdelmann
FloEdelmann merged commit 6a4ff1b into vuejs:master Aug 12, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npm run new fails when VS Code CLI is not installed

2 participants