diff --git a/package.json b/package.json index 6f954a6..ef1a94a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ci-task-runner", - "version": "1.0.4-beta", + "version": "1.0.4", "description": "this is a multiprocess building tasks scheduler", "main": "src/index.js", "bin": "bin/ci-task-runner", diff --git a/src/run-cmd.js b/src/run-cmd.js index 6ff5f93..7e617bd 100644 --- a/src/run-cmd.js +++ b/src/run-cmd.js @@ -18,11 +18,10 @@ const run = (cmd, { env, cwd, uid, gid }, callback) => { proc.on('error', procError); proc.on('close', function (code, signal) { - let er; if (signal) { process.kill(process.pid, signal); } else if (code) { - er = new Error('Exit status ' + code); + const er = new Error(`child process exited with code ${code}`); er.errno = code; procError(er) } else { @@ -89,7 +88,7 @@ module.exports = (command, options = {}) => { clearTimeout(timer); if (errors) { - errors.messsage = `"${command}": ${errors.messsage}`; + errors.message = `run "${command}" failed: ${errors.message}`; reject(errors); } else { resolve(data); diff --git a/src/run-tasks.js b/src/run-tasks.js index 0f931a8..c51b224 100644 --- a/src/run-tasks.js +++ b/src/run-tasks.js @@ -1,6 +1,6 @@ const queue = require('./queue'); const Loger = require('./loger'); -const worker = require('./run-cmd'); +const runCmd = require('./run-cmd'); const PACKAGE = require('../package.json'); @@ -30,7 +30,7 @@ module.exports = (tasks, parallel = require('os').cpus().length) => { const loger = new Loger([null, ...logStyles]); loger.log('░░', `${PACKAGE.name}:`, task.name, '[running]'); - return worker(program.command, program.options).then(() => { + return runCmd(program.command, program.options).then(() => { const loger = new Loger([{ color: 'green' }, ...logStyles]); const timeEnd = Math.round((Date.now() - time) / 1000) diff --git a/test/run-cmd.test.js b/test/run-cmd.test.js index 8141a1f..bd53b26 100644 --- a/test/run-cmd.test.js +++ b/test/run-cmd.test.js @@ -1,13 +1,13 @@ const assert = require('assert'); -const worker = require('../src/run-cmd'); +const runCmd = require('../src/run-cmd'); -describe('#worker', () => { +describe('#runCmd', () => { it('exec script', () => { - return worker('echo "hello"'); + return runCmd('echo "hello"'); }); // it('childProcess.exec error', () => { - // return worker("", { + // return runCmd("", { // cwd: {} // }).then(() => { // throw new Error('error'); @@ -17,7 +17,7 @@ describe('#worker', () => { // }); it('exec error', () => { - return worker(`@error%`, { + return runCmd(`@error%`, { timeout: 100 }).then(() => { throw new Error('error'); @@ -27,7 +27,7 @@ describe('#worker', () => { }); it('options.timeout', () => { - return worker(`node -e "setTimeout(()=> {}, 3000)"`, { + return runCmd(`node -e "setTimeout(()=> {}, 3000)"`, { timeout: 100 }).then(() => { throw new Error('options.timeout: error');