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

Feature: exclude folders from scan #227

Open
wants to merge 4 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
7 changes: 5 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const cli = meow({
-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.
--ignore-dirs Ignore paths - directory names to ignore.
--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.
Expand Down Expand Up @@ -68,7 +69,8 @@ const cli = meow({
],
string: [
'ignore',
'specials'
'specials',
'ignore-dirs'
]
});

Expand All @@ -85,7 +87,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
20 changes: 11 additions & 9 deletions lib/in/get-unused-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ function checkUnused(currentState) {
const spinner = ora(`Checking for unused packages. --skip-unused if you don't want this.`);
spinner.enabled = spinner.enabled && currentState.get('spinner');
spinner.start();
const defaultIgnoreDirs = [
'sandbox',
'dist',
'generated',
'.generated',
'build',
'fixtures',
'jspm_packages'
];
const ignoreDirs = defaultIgnoreDirs.concat(currentState.get('ignoreDirs'));

return new Promise(resolve => {
if (skipUnused(currentState)) {
Expand All @@ -32,15 +42,7 @@ function checkUnused(currentState) {
}

const depCheckOptions = {
ignoreDirs: [
'sandbox',
'dist',
'generated',
'.generated',
'build',
'fixtures',
'jspm_packages'
],
ignoreDirs: ignoreDirs,
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: [],

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