@bowtie/cli
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "@bowtie/cli", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Internal BowTie CLI Tools", | ||
@@ -28,4 +28,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"cmr1-cli": "^0.1.6" | ||
"cmr1-cli": "^0.1.8", | ||
"shelljs": "^0.7.8" | ||
} | ||
} |
const Cmr1Cli = require('cmr1-cli'); | ||
const actions = require('./actions'); | ||
const ACTIONS = [ | ||
'clean', | ||
'build', | ||
'test' | ||
] | ||
const additionalOptions = [ | ||
@@ -17,3 +12,3 @@ { | ||
description: 'Action to take', | ||
typeLabel: ACTIONS.map(a => `[underline]{${a}}`).join(' | ') | ||
typeLabel: Object.keys(actions).map(a => `[underline]{${a}}`).join(' | ') | ||
} | ||
@@ -30,7 +25,17 @@ ]; | ||
const handleAction = (action) => { | ||
if (ACTIONS.indexOf(action) === -1) { | ||
cli.warn('Invalid action!'); | ||
cli.debug(`Finding action: ${action}`); | ||
cli.debug('Available actions:', JSON.stringify(Object.keys(actions), null, 2)); | ||
if (!actions[action]) { | ||
cli.warn(`Action: '${action}' is invalid`); | ||
cli.showHelp(); | ||
} else { | ||
console.log('Running Action: ' + action); | ||
cli.log(`Running action: ${action}`); | ||
if (typeof actions[action] === 'function') { | ||
actions[action](); | ||
} else { | ||
cli.warn(`Action: '${action}' is invalid`); | ||
cli.showHelp(); | ||
} | ||
} | ||
@@ -41,4 +46,12 @@ } | ||
run: () => { | ||
cli.options.action.forEach(handleAction); | ||
cli.debug('Running with options:'); | ||
cli.debug(JSON.stringify(cli.options, null, 2)); | ||
if (cli.options.action) { | ||
cli.options.action.forEach(handleAction); | ||
} else { | ||
cli.warn('Missing action!'); | ||
cli.showHelp(); | ||
} | ||
} | ||
} |
2976
12
71
2
+ Addedshelljs@^0.7.8
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinterpret@1.4.0(transitive)
+ Addedis-core-module@2.16.1(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedrechoir@0.6.2(transitive)
+ Addedresolve@1.22.10(transitive)
+ Addedshelljs@0.7.8(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
Updatedcmr1-cli@^0.1.8