package-menu-cli
Advanced tools
Comparing version 1.3.2 to 1.3.3
{ | ||
"name": "package-menu-cli", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "Displays menu of scripts from directory containing `package.json`", | ||
@@ -5,0 +5,0 @@ "main": "cli.js", |
/*global require*/ | ||
const chalk = require('chalk'); | ||
const Table = require('cli-table2'); // INFO: https://www.npmjs.com/package/cli-table2 | ||
const Table = require('cli-table2'); // INFO: https://www.npmjs.com/package/cli-table2 | ||
const fs = require('fs'); | ||
@@ -9,44 +9,42 @@ | ||
console.log(opts); | ||
if (!pkgInfo.hasOwnProperty('scripts')) { | ||
return {error: true, message: 'package.json does not contain any scripts'}; | ||
} | ||
if (!pkgInfo.hasOwnProperty('scripts')) { | ||
return {error: true, message: 'package.json does not contain any scripts'}; | ||
} | ||
let table; | ||
let table; | ||
// instantiate | ||
if (opts.compress) { | ||
table = new Table({ | ||
head: ['Name'] | ||
}); | ||
} | ||
else { | ||
table = new Table({ | ||
head: ['Name', 'Script'], | ||
colWidths: [20] | ||
}); | ||
} | ||
// instantiate | ||
if (opts.compress) { | ||
table = new Table({ | ||
head: ['Name'] | ||
}); | ||
} | ||
else { | ||
table = new Table({ | ||
head: ['Name', 'Script'], | ||
colWidths: [20] | ||
}); | ||
} | ||
const scripts = pkgInfo.scripts; | ||
const scriptNames = Object.keys(scripts); | ||
const scripts = pkgInfo.scripts; | ||
const scriptNames = Object.keys(scripts); | ||
if (opts.sort) { | ||
scriptNames.sort(); | ||
} | ||
if (!opts.compress) { | ||
scriptNames.map((item) => { | ||
table.push( | ||
[item, scripts[item]] | ||
); | ||
}); | ||
} | ||
else { | ||
scriptNames.map((item) => { | ||
table.push([item]); | ||
}); | ||
} | ||
if (opts.sort) { | ||
scriptNames.sort(); | ||
} | ||
if (!opts.compress) { | ||
scriptNames.map((item) => { | ||
table.push( | ||
[item, scripts[item]] | ||
); | ||
}); | ||
} | ||
else { | ||
scriptNames.map((item) => { | ||
table.push([item]); | ||
}); | ||
} | ||
return table; | ||
return table; | ||
} | ||
@@ -53,0 +51,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11535
10
160
1