Skip to content

Commit

Permalink
Upgrade: dependencies
Browse files Browse the repository at this point in the history
- Some code were modified for `arrow-body-style` rule.
- Babel is still 5.x in order to work plugins.
  • Loading branch information
mysticatea committed Nov 5, 2015
1 parent ac0282f commit daad55f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 41 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"test": "npm run lint && istanbul cover node_modules/mocha/bin/_mocha -- test/*.js --require mocha-babel-hook --timeout 30000",
"testing": "mocha test/*.js --require mocha-babel-hook --timeout 30000 --watch --growl",
"coveralls": "cat coverage/lcov.info | coveralls",
"start": "node test/tasks/append.js start",
"stop": "node test/tasks/append.js stop",
"test-task:env-check": "node test/tasks/env-check.js",
"test-task:append": "node test/tasks/append.js",
"test-task:append:a": "node test/tasks/append.js a",
Expand All @@ -36,13 +38,13 @@
"which": "^1.2.0"
},
"devDependencies": {
"babel": "^5.8.23",
"babel-core": "^5.8.25",
"babel": "^5.8.29",
"babel-core": "^5.8.33",
"babel-plugin-espower": "^1.0.0",
"babel-plugin-unassert": "^1.2.0",
"coveralls": "^2.11.4",
"eslint": "^1.7.1",
"eslint-config-mysticatea": "^1.7.0",
"eslint": "^1.8.0",
"eslint-config-mysticatea": "^1.8.0",
"eslint-plugin-mysticatea": "^1.0.2",
"istanbul": "^0.4.0",
"mocha": "^2.3.3",
Expand Down
38 changes: 20 additions & 18 deletions src/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,26 @@ export default function main(

let currentPromise = null;
let aborted = false;
const resultPromise = queue.reduce((prevPromise, group) => {
return prevPromise.then(() => {
if (group == null || group.tasks.length === 0 || aborted) {
return undefined;
}

currentPromise = runAll(
group.tasks,
{
stdout,
stderr,
stdin: process.stdin,
parallel: group.parallel
});

return currentPromise;
});
}, SUCCESS);
const resultPromise = queue.reduce(
(prevPromise, group) =>
prevPromise.then(() => {
if (group == null || group.tasks.length === 0 || aborted) {
return undefined;
}

currentPromise = runAll(
group.tasks,
{
stdout,
stderr,
stdin: process.stdin,
parallel: group.parallel
});

return currentPromise;
}),
SUCCESS
);

// Define abort method.
resultPromise.abort = function abort() {
Expand Down
32 changes: 17 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,24 @@ function filterTasks(taskList, patterns) {
function runAllSequencially(tasks, stdin, stdout, stderr) {
let currentPromise = null;
let aborted = false;
const resultPromise = tasks.reduce((prevPromise, task) => {
return prevPromise.then(() => {
if (aborted) {
return undefined;
}

currentPromise = runTask(task, stdin, stdout, stderr);
return currentPromise.then(item => {
currentPromise = null;
if (item.code !== 0 && item.code != null) {
throw new Error(
`${item.task}: None-Zero Exit(${item.code});`);
const resultPromise = tasks.reduce(
(prevPromise, task) =>
prevPromise.then(() => {
if (aborted) {
return undefined;
}
});
});
}, Promise.resolve());

currentPromise = runTask(task, stdin, stdout, stderr);
return currentPromise.then(item => {
currentPromise = null;
if (item.code !== 0 && item.code != null) {
throw new Error(
`${item.task}: None-Zero Exit(${item.code});`);
}
});
}),
Promise.resolve()
);

// Define abort method.
resultPromise.abort = function abort() {
Expand Down
8 changes: 4 additions & 4 deletions src/run-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ function detectStreamKind(stream, std) {
*/
export default function runTask(task, stdin, stdout, stderr) {
let cp = null;
const promise = lookupNpm().then(npmPath => {
return new Promise((resolve, reject) => {
const promise = lookupNpm().then(npmPath =>
new Promise((resolve, reject) => {
const stdinKind = detectStreamKind(stdin, process.stdin);
const stdoutKind = detectStreamKind(stdout, process.stdout);
const stderrKind = detectStreamKind(stderr, process.stderr);
Expand All @@ -159,8 +159,8 @@ export default function runTask(task, stdin, stdout, stderr) {
cp = null;
resolve({task, code});
});
});
});
})
);

promise.kill = function kill() {
if (cp != null) {
Expand Down

0 comments on commit daad55f

Please sign in to comment.