Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
aui committed Jul 21, 2017
1 parent 854e108 commit ee6ab42
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 2 additions & 3 deletions src/run-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/run-tasks.js
Original file line number Diff line number Diff line change
@@ -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');


Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions test/run-cmd.test.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -17,7 +17,7 @@ describe('#worker', () => {
// });

it('exec error', () => {
return worker(`@error%`, {
return runCmd(`@error%`, {
timeout: 100
}).then(() => {
throw new Error('error');
Expand All @@ -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');
Expand Down

0 comments on commit ee6ab42

Please sign in to comment.