Comparing version 1.5.2 to 1.6.0
@@ -5,3 +5,3 @@ { | ||
"max-len": [ 0 ], | ||
"max-statements": [ 2, { "maximum": 16 }, { "ignoreTopLevelFunctions": true } ], | ||
"max-statements": [ 2, { "maximum": 20 }, { "ignoreTopLevelFunctions": true } ], | ||
"no-process-env": [ 0 ], | ||
@@ -8,0 +8,0 @@ "require-jsdoc": [ 0 ] |
@@ -19,2 +19,3 @@ #!/usr/bin/env node | ||
.option( '-e, --exec <command>', 'Command to execute when opted-in to or not opted-out of the given rule' ) | ||
.option( '-l, --list', 'List explicitly set opt-in and opt-out rules' ) | ||
.option( '--verbose', 'Output additional details' ); | ||
@@ -53,4 +54,7 @@ | ||
// invalid arguments: "in" OR "out" have to be specified, as well es "exec" | ||
if ( ( program.in && program.out ) || ( !program.in && !program.out ) || !program.exec ) { | ||
// invalid arguments: ("in" OR "out" have to be specified, as well es "exec") OR "list" has to be requested | ||
if ( | ||
( ( program.in && program.out ) || ( !program.in && !program.out ) || !program.exec ) && | ||
!program.list | ||
) { | ||
program.help(); | ||
@@ -77,2 +81,8 @@ | ||
if ( program.list ) { | ||
listExplicitOpts(); | ||
return; | ||
} | ||
// prepare PATH env var to include cwd/node_modules/bin | ||
@@ -86,1 +96,33 @@ alteredEnvPath = managePath( env ); | ||
} | ||
function listExplicitOpts() { | ||
var explictOpts = opt.getExplicitOpts(), | ||
flags = Object.keys( explictOpts ), // eslint-disable-line id-match | ||
sorted = { in: [], out: [] }, | ||
output = []; | ||
// Filter results to print in-out | ||
sorted = flags.reduce( | ||
function sortExplicit( accumulator, key ) { | ||
accumulator[ explictOpts[ key ] ? 'in' : 'out' ].push( key ); | ||
return accumulator; | ||
}, | ||
sorted | ||
); | ||
if ( sorted.in.length ) { | ||
output.push( 'Opted-in to:\n' + ' - ' + sorted.in.join( '\n - ' ) ); | ||
} | ||
if ( sorted.out.length ) { | ||
output.push( 'Opted-out of:\n' + ' - ' + sorted.out.join( '\n - ' ) ); | ||
} | ||
if ( !flags.length ) { | ||
output.push( 'No explict opt-in or opt-out configuration found.' ); | ||
} | ||
// eslint-disable-next-line no-console | ||
console.log( output.join( '\n\n' ) ); | ||
} |
{ | ||
"name": "opt-cli", | ||
"version": "1.5.2", | ||
"version": "1.6.0", | ||
"description": "Execute CLI Statements based upon Opt-In / Opt-Out Rules.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9
20198
11
220
1