Skip to content

Commit

Permalink
ci: ensure npx compatibility with npm v7
Browse files Browse the repository at this point in the history
As of now, `npx` in npm v6 does not prompt about the package about to
be used.

But things change with npm v7 where `npx` now prompts before installing
anything.

https://docs.npmjs.com/cli/v7/commands/npx

> To prevent security and user-experience problems from mistyping
> package names, `npx` prompts before installing anything. Suppress this
> prompt with the `-y` or `--yes` option.

However this flag `--yes` is not supported by npm v6 and would result in
an error if used. We need to set that flag through `npm_config_`:

https://docs.npmjs.com/cli/v6/using-npm/config

> Any environment variables that start with `npm_config_` will be
> interpreted as a configuration parameter. For example, putting
> `npm_config_foo=bar` in your environment will set the `foo`
> configuration parameter to `bar`. Any environment configurations that
> are not given a value will be given the value of true. Config values
> are case-insensitive, so `NPM_CONFIG_FOO=bar` will work the same.

See:
- https://dev.to/omrilotan/npx-breaking-on-ci-48ak
  • Loading branch information
MrChocolatine committed Oct 28, 2021
1 parent f766b67 commit 6ebd9a5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ jobs:

# https://github.com/lirantal/lockfile-lint
- name: Lint lockfile
run: npx lockfile-lint --path yarn.lock --allowed-hosts npm yarn --validate-https
run: npm_config_yes=true npx lockfile-lint \
--path yarn.lock \
--allowed-hosts npm yarn \
--validate-https

- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand Down

0 comments on commit 6ebd9a5

Please sign in to comment.