Skip to content

Instantly share code, notes, and snippets.

@brentvatne
Last active November 17, 2017 10:43
Show Gist options
  • Save brentvatne/6390909075b02811ef5384d5b7c41ab2 to your computer and use it in GitHub Desktop.
Save brentvatne/6390909075b02811ef5384d5b7c41ab2 to your computer and use it in GitHub Desktop.
// Assumes you have ag installed, `brew install the_silver_searcher`
const fs = require('fs');
const packageJson = fs.readFileSync('./package.json');
const dependencies = Object.keys(JSON.parse(packageJson).dependencies);
const { execSync } = require('child_process');
dependencies.forEach(dep => {
try {
let result = execSync(`ag '${dep}' --ignore node_modules --ignore package.json --ignore yarn.lock --ignore package-lock.json`);
} catch(e) {
console.log(`${dep} is unused`);
}
});
@eschaefer
Copy link

eschaefer commented Nov 16, 2017

Awesome, thanks! Ripgrep is even faster than ag, also available w/ brew!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment