Skip to content

Commit

Permalink
chore(package.json): shouldn't use the --yes option with the npx
Browse files Browse the repository at this point in the history
…command

The `npx` command included with npm v6 does not allow the `--yes` option.
However, the `npx` command included with npm v7 and later will print a prompt if the `--yes` option is not added.

To solve this problem, we decided to include `only-allow` in the dev dependencies for this project.
This will ensure that `only-allow` is executed correctly in each version of the `npx` command:

+ If using npm v6, the `--yes` option is not necessary.
  npx will run `only-allow` without prompting.
+ If using npm v7 or later, the `npm install` command will install the dependencies before running the `preinstall` script.
  `only-allow` is included in the dependencies, so npx will not fetch `only-allow` from remote.
  Therefore, npx will not print a prompt.
  • Loading branch information
sounisi5011 committed Feb 26, 2023
1 parent fe7b655 commit fe4cb64
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"fmt:ts:eslint": "eslint --cache --report-unused-disable-directives --fix --ext .ts,.cts,.mts ./",
"fmt:xs": "npm-run-all fmt:xs:eslint --parallel fmt:{ts,js}:dprint fmt:xs:eslint",
"fmt:xs:eslint": "run-s 'lint:eslint -- --fix'",
"preinstall": "npx --yes only-allow pnpm",
"preinstall": "npx only-allow pnpm",
"lint": "run-p lint:*",
"lint:actions": "actionlint",
"lint:eslint": "eslint --cache --report-unused-disable-directives ./",
Expand Down Expand Up @@ -70,6 +70,7 @@
"husky": "8.0.3",
"lint-staged": "13.1.0",
"npm-run-all": "4.1.5",
"only-allow": "1.1.1",
"prettier": "2.8.2",
"prettier-package-json": "2.8.0",
"sort-package-json": "2.1.0",
Expand Down
60 changes: 60 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fe4cb64

Please sign in to comment.