Skip to content

Instantly share code, notes, and snippets.

@aalemayhu
Created December 11, 2023 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aalemayhu/d89ce210674335f81c6463124bffbf44 to your computer and use it in GitHub Desktop.
Save aalemayhu/d89ce210674335f81c6463124bffbf44 to your computer and use it in GitHub Desktop.
Example of finding unused npm packages using git grep
import { exec } from 'node:child_process';
import packages from './package.json';
for (const pkg in packages.dependencies) {
exec(`"/usr/local/bin/git" grep ${pkg} src`, (err, stdout, stderr) => {
if (err) {
console.log(`${pkg} can be removed`);
}
});
}
console.log('done');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment