Skip to content

Commit

Permalink
feat: support disabling updates to lock files
Browse files Browse the repository at this point in the history
- changes related to dylang#425
  • Loading branch information
Tom Zellman committed Jul 18, 2022
1 parent eff52bc commit 61f339b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Install packages using `--save-exact`, meaning exact versions will be saved in p

Applies to both `dependencies` and `devDependencies`.


#### `--specials`

Check special (e.g. config) files when looking for unused dependencies.
Expand All @@ -167,6 +168,10 @@ By default `npm-check` uses colors if they are available.

Enable or disable emoji support. Useful for terminals that don't support them. Automatically disabled in CI servers.

#### `--lock, --no-lock`

Enable or disable lock file updates. Enabled by default.

#### `--spinner, --no-spinner`

Enable or disable the spinner. Useful for terminals that don't support them. Automatically disabled in CI servers.
Expand Down
6 changes: 6 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const cli = meow(`
--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.
--no-lock No updates will be made to lock files.
--debug Debug output. Throw in a gist when creating issues on github.
Examples
Expand Down Expand Up @@ -87,6 +88,10 @@ const cli = meow(`
type: 'boolean',
default: !isCI
},
lock: {
type: 'boolean',
default: true
},
debug: {
type: 'boolean'
},
Expand All @@ -110,6 +115,7 @@ const options = {
saveExact: cli.flags.saveExact,
specials: cli.flags.specials,
emoji: cli.flags.emoji,
lockFile: cli.flags.lock,
installer: process.env.NPM_CHECK_INSTALLER || 'auto',
debug: cli.flags.debug,
spinner: cli.flags.spinner,
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 @@ -16,12 +16,14 @@ function install(packages, currentState) {

const installGlobal = currentState.get('global') ? (isYarn ? 'global' : '--global'): null;
const saveExact = currentState.get('saveExact') ? (isYarn ? '--exact' : '--save-exact') : null;
const lockFile = !currentState.get('lockFile') ? (isYarn ? '--no-lockfile' : '--no-package-lock') : null;

const installCmd = isYarn ? 'add' : 'install';

const npmArgs = [installCmd]
.concat(installGlobal)
.concat(saveExact)
.concat(lockFile)
.concat(packages)
.concat(color)
.filter(Boolean);
Expand Down
1 change: 1 addition & 0 deletions lib/state/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const defaultOptions = {
specials: '',
debug: false,
emoji: true,
lockFile: true,
spinner: false,
installer: 'npm',
ignore: [],
Expand Down

0 comments on commit 61f339b

Please sign in to comment.