-
-
Save aalemayhu/d89ce210674335f81c6463124bffbf44 to your computer and use it in GitHub Desktop.
Example of finding unused npm packages using git grep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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