Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds support for legacy-peer-deps flag on npm install #4

Merged
merged 1 commit into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ const cli = meow(`
Where to check. Defaults to current directory. Use -g for checking global modules.

Options
-u, --update Interactive update.
-y, --update-all Uninteractive update. Apply all updates without prompting.
-g, --global Look at global modules.
-s, --skip-unused Skip check for unused packages.
-p, --production Skip devDependencies.
-d, --dev-only Look at devDependencies only (skip dependencies).
-i, --ignore Ignore dependencies based on succeeding glob.
-E, --save-exact Save exact version (x.y.z) instead of caret (^x.y.z) in package.json.
--specials List of depcheck specials to include in check for unused dependencies.
--no-color Force or disable color output.
--no-emoji Remove emoji support. No emoji in default in CI environments.
--debug Debug output. Throw in a gist when creating issues on github.
-u, --update Interactive update.
-y, --update-all Uninteractive update. Apply all updates without prompting.
-g, --global Look at global modules.
-s, --skip-unused Skip check for unused packages.
-p, --production Skip devDependencies.
-d, --dev-only Look at devDependencies only (skip dependencies).
-i, --ignore Ignore dependencies based on succeeding glob.
-E, --save-exact Save exact version (x.y.z) instead of caret (^x.y.z) in package.json.
-l, --legacy-peer-deps Disable automatic installation of peer dependencies.
--specials List of depcheck specials to include in check for unused dependencies.
--no-color Force or disable color output.
--no-emoji Remove emoji support. No emoji in default in CI environments.
--debug Debug output. Throw in a gist when creating issues on github.

Examples
$ npm-check # See what can be updated, what isn't being used.
Expand Down Expand Up @@ -82,6 +83,10 @@ const cli = meow(`
type: 'string',
alias: 'i'
},
legacyPeerDeps: {
type: 'boolean',
alias: 'l'
},
specials: {
type: 'string'
},
Expand Down Expand Up @@ -118,7 +123,8 @@ const options = {
installer: process.env.NPM_CHECK_INSTALLER || 'auto',
debug: cli.flags.debug,
spinner: cli.flags.spinner,
ignore: cli.flags.ignore
ignore: cli.flags.ignore,
legacyPeerDeps: cli.flags.legacyPeerDeps,
};

if (options.debug) {
Expand Down
2 changes: 2 additions & 0 deletions lib/out/install-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function install(packages, currentState) {

const installer = currentState.get('installer');
const color = chalk.supportsColor ? '--color=always' : null;
const legacyPeerDeps = currentState.get("legacyPeerDeps") ? "--legacy-peer-deps" : null;

const isYarn = installer === 'yarn';

Expand All @@ -22,6 +23,7 @@ function install(packages, currentState) {
.concat(saveExact)
.concat(packages)
.concat(color)
.concat(legacyPeerDeps)
.filter(Boolean);

console.log('');
Expand Down
1 change: 1 addition & 0 deletions lib/state/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const defaultOptions = {
spinner: false,
installer: 'npm',
ignore: [],
legacyPeerDeps: false,

globalPackages: {},
cwdPackageJson: {devDependencies: {}, dependencies: {}},
Expand Down