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

Add "ignoreDirs" option #221

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Options
-p, --production Skip devDependencies.
-d, --dev-only Look at devDependencies only (skip dependencies).
-i, --ignore Ignore dependencies based on succeeding glob.
-D, --ignore-dirs Ignore directories as passed into depcheck.
-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.
Expand Down Expand Up @@ -137,6 +138,12 @@ Ignore dependencies that match specified glob.

`$ npm-check -i babel-*` will ignore all dependencies starting with 'babel-'.

#### `-D, --ignore-dirs`

Ignore a comma-separated list of directories as passed into depcheck.

`$ npm-check -D "tmp,build"` will avoid searching the 'tmp' and 'build' directories when using depcheck.

#### `-E, --save-exact`

Install packages using `--save-exact`, meaning exact versions will be saved in package.json.
Expand Down Expand Up @@ -208,6 +215,11 @@ npmCheck(options)
* Ignore dependencies that match specified glob.
* default is `[]`

#### `ignoreDirs`

* Ignore comma-separated list of directories as passed into depcheck.
* default is `['sandbox', 'dist', 'generated', '.generated', 'build', 'fixtures', 'jspm_packages']`

#### `saveExact`

* Update package.json with exact version `x.y.z` instead of semver range `^x.y.z`.
Expand Down
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare module NpmCheck {
skipUnused?: boolean;
devOnly?: boolean;
ignoreDev?: boolean;
ignoreDirs?: string;
cwd?: string;
saveExact?: boolean;
currentState?: Object;
Expand Down Expand Up @@ -48,4 +49,4 @@ declare module NpmCheck {

declare module "npm-check" {
export = NpmCheck.default;
}
}
8 changes: 6 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const cli = meow({
-p, --production Skip devDependencies.
-d, --dev-only Look at devDependencies only (skip dependencies).
-i, --ignore Ignore dependencies based on succeeding glob.
-D, --ignore-dirs Ignore directories as passed into depcheck.
-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.
Expand All @@ -48,7 +49,8 @@ const cli = meow({
p: 'production',
d: 'dev-only',
E: 'save-exact',
i: 'ignore'
i: 'ignore',
D: 'ignore-dirs'
},
default: {
dir: pkgDir.sync() || process.cwd(),
Expand All @@ -68,6 +70,7 @@ const cli = meow({
],
string: [
'ignore',
'ignore-dirs',
'specials'
]
});
Expand All @@ -85,7 +88,8 @@ const options = {
installer: process.env.NPM_CHECK_INSTALLER || 'npm',
debug: cli.flags.debug,
spinner: cli.flags.spinner,
ignore: cli.flags.ignore
ignore: cli.flags.ignore,
ignoreDirs: cli.flags.ignoreDirs
};

if (options.debug) {
Expand Down
11 changes: 2 additions & 9 deletions lib/in/get-unused-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,9 @@ function checkUnused(currentState) {
return;
}

let ignoreDirs = currentState.get('ignoreDirs');
const depCheckOptions = {
ignoreDirs: [
'sandbox',
'dist',
'generated',
'.generated',
'build',
'fixtures',
'jspm_packages'
],
ignoreDirs: Array.isArray(ignoreDirs) ? ignoreDirs : ignoreDirs.split(/,\s*/),
ignoreMatches: [
'gulp-*',
'grunt-*',
Expand Down
1 change: 1 addition & 0 deletions lib/state/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const defaultOptions = {
spinner: false,
installer: 'npm',
ignore: [],
ignoreDirs: ['sandbox', 'dist', 'generated', '.generated', 'build', 'fixtures', 'jspm_packages'],

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