Comparing version 3.2.0 to 3.3.0
{ | ||
"name": "devlab", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Node utility for running containerized tasks", | ||
@@ -29,7 +29,6 @@ "keywords": [ | ||
"scripts": { | ||
"test": "npm run lint -s && npm run cover -s", | ||
"test": "npm run lint -s && npm run test:cover -s", | ||
"test:cover": "istanbul cover _mocha test/src/**/*.spec.js", | ||
"test:watch": "nodemon --exec \"npm run test:cover || exit 1\"", | ||
"e2e": "node test/system/run.js", | ||
"mocha": "mocha test/src/**/*.spec.js", | ||
"mocha:watch": "nodemon --exec \"mocha test/src/**/*.spec.js || exit 1\"", | ||
"cover": "istanbul cover _mocha test/src/**/*.spec.js", | ||
"lint": "standard --fix --verbose" | ||
@@ -36,0 +35,0 @@ }, |
@@ -27,2 +27,3 @@ 'use strict' | ||
'c': { prop: 'configPath', help: 'Run with custom config file path' }, | ||
'tasks': { action: 'tasks', help: 'List all available tasks' }, | ||
'cleanup': { action: 'cleanupDL', help: 'Stops and removes any non-persisted Devlab containers' }, | ||
@@ -32,2 +33,9 @@ 'cleanup-all': { action: 'cleanupAll', help: 'Stops and removes ALL docker containers' } | ||
/** | ||
* List all available tasks | ||
*/ | ||
tasks: () => { | ||
utils.tasks() | ||
process.exit(0) | ||
}, | ||
/** | ||
* Displays the help and usage message | ||
@@ -34,0 +42,0 @@ */ |
@@ -30,3 +30,3 @@ const _ = require('redash') | ||
/** | ||
* Parses config object and returns conatiner name. Will have dl_ prefix and | ||
* Parses config object and returns container name. Will have dl_ prefix and | ||
* InstanceID suffix if ephemeral, unaltered name for persisted containers | ||
@@ -33,0 +33,0 @@ * @param {object} cfg Config object |
@@ -80,9 +80,9 @@ const _ = require('redash') | ||
}) | ||
.catch((e) => { | ||
services.stop() | ||
output.error(e.message || 'Process failed') | ||
throw new Error('Process failed') | ||
}) | ||
.catch((e) => { | ||
services.stop() | ||
output.error(e.message || 'Process failed') | ||
throw new Error('Process failed') | ||
}) | ||
} | ||
module.exports = instance |
@@ -6,3 +6,18 @@ const _ = require('redash') | ||
const pad = (len, str) => str.length < len ? str + ' '.repeat(len - str.length) : str | ||
const utils = { | ||
tasks: () => { | ||
const cfg = require('./config').load() | ||
const tasks = _.keys(cfg.tasks) | ||
const maxTaskLen = _.pipe([ | ||
_.map(_.prop('length')), | ||
_.max | ||
])(tasks) | ||
console.log([ | ||
'', | ||
'Tasks:', | ||
..._.map(task => ` ${pad(maxTaskLen + 4, task)}${cfg.tasks[task]}`, tasks) | ||
].join('\n')) | ||
}, | ||
/** | ||
@@ -9,0 +24,0 @@ * Runs docker stop && docker rm on containers currently running |
21350
564