Skip to content

Revert "Issue #12" #16

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

Merged
merged 1 commit into from
Aug 28, 2022
Merged
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
22 changes: 10 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ const walkModules = ((path = 'node_modules') => {
dirTree(path, {extensions:/\.json$/}, (item) => {

if (item.name === 'package.json') {
try{
let pkg = JSON.parse(fs.readFileSync(item.path, 'utf8'));
if (!pkg || !pkg.scripts) return;
let scripts = Object.keys(pkg.scripts);
scripts.forEach((script) => {
if (scriptTypes.includes(script)) {
reports.push({ name: pkg.name, script: script, src:item.path })
}
});
catch(e){
}
let pkg = JSON.parse(fs.readFileSync(item.path, 'utf8'));
if (!pkg.scripts) return;
let scripts = Object.keys(pkg.scripts);
scripts.forEach((script) => {
if (scriptTypes.includes(script)) {
reports.push({name: pkg.name, script: script})
}
});

}

});
Expand All @@ -32,7 +30,7 @@ process.on('exit', () => {
} else {
console.log('\x1b[31m', 'Potentially unsafe scripts found. These should be reviewed for safety', '\x1b[0m');
reports.forEach((report) => {
console.log(`Module name: ${report.name} Type: ${report.script} Src: ${report.src}` );
console.log(`Module name: ${report.name} Type: ${report.script}`);
});
}

Expand Down