Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function removeBins (
uninstalledPkg: string,
opts: {
dryRun?: boolean,
modulesDir: string,
binsDir: string,
},
) {
const uninstalledPkgPath = path.join(opts.modulesDir, uninstalledPkg)
const uninstalledPkgJson = await safeReadPackageFromDir(uninstalledPkgPath) as DependencyManifest
if (!uninstalledPkgJson) return
const cmds = await binify(uninstalledPkgJson, uninstalledPkgPath)
if (!opts.dryRun) {
// TODO: what about the .cmd bin files on Windows?
await Promise.all(
cmds
.map((cmd) => path.join(opts.binsDir, cmd.name))
.map(remove),
)
}
return uninstalledPkgJson
}