-
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
dff6409
commit e07e782
Showing
10 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict" | ||
|
||
const text = process.argv[2] | ||
const timeout = process.argv[3] | ||
|
||
process.stdout.write(`[${text}]`) | ||
setTimeout(() => process.stdout.write(`__[${text}]\n`), timeout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
|
||
/** | ||
* @author Toru Nagashima | ||
* @copyright 2016 Toru Nagashima. All rights reserved. | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
"use strict" | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
|
||
const assert = require("power-assert") | ||
const nodeApi = require("../lib") | ||
const BufferStream = require("./lib/buffer-stream") | ||
const util = require("./lib/util") | ||
const runAll = util.runAll | ||
const runPar = util.runPar | ||
const runSeq = util.runSeq | ||
|
||
//------------------------------------------------------------------------------ | ||
// Test | ||
//------------------------------------------------------------------------------ | ||
|
||
describe("[aggregated-output] npm-run-all", () => { | ||
before(() => process.chdir("test-workspace")) | ||
after(() => process.chdir("..")) | ||
|
||
/** | ||
* create expected text | ||
* @param {string} term the term to use when creating a line | ||
* @returns {string} the complete line | ||
*/ | ||
function createExpectedOutput(term) { | ||
return `[${term}]__[${term}]` | ||
} | ||
|
||
describe("should not intermingle output of various commands", () => { | ||
const EXPECTED_SERIALIZED_TEXT = [ | ||
createExpectedOutput("first"), | ||
createExpectedOutput("second"), | ||
`${createExpectedOutput("third")}\n`, | ||
].join("\n") | ||
|
||
const EXPECTED_PARALLELIZED_TEXT = [ | ||
createExpectedOutput("second"), | ||
createExpectedOutput("third"), | ||
`${createExpectedOutput("first")}\n`, | ||
].join("\n") | ||
|
||
let stdout = null | ||
|
||
beforeEach(() => { | ||
stdout = new BufferStream() | ||
}) | ||
|
||
it("Node API", () => nodeApi( | ||
["test-task:delayed first 300", "test-task:delayed second 100", "test-task:delayed third 200"], | ||
{stdout, silent: true, aggregateOutput: true} | ||
) | ||
.then(() => { | ||
assert.equal(stdout.value, EXPECTED_SERIALIZED_TEXT) | ||
})) | ||
|
||
it("npm-run-all command", () => runAll( | ||
["test-task:delayed first 300", "test-task:delayed second 100", "test-task:delayed third 200", "--silent", "--aggregate-output"], | ||
stdout | ||
) | ||
.then(() => { | ||
assert.equal(stdout.value, EXPECTED_SERIALIZED_TEXT) | ||
})) | ||
|
||
it("run-s command", () => runSeq( | ||
["test-task:delayed first 300", "test-task:delayed second 100", "test-task:delayed third 200", "--silent", "--aggregate-output"], | ||
stdout | ||
) | ||
.then(() => { | ||
assert.equal(stdout.value, EXPECTED_SERIALIZED_TEXT) | ||
})) | ||
|
||
it("run-p command", () => runPar([ | ||
"test-task:delayed first 3000", | ||
"test-task:delayed second 1000", | ||
"test-task:delayed third 2000", | ||
"--silent", "--aggregate-output"], | ||
stdout | ||
) | ||
.then(() => { | ||
assert.equal(stdout.value, EXPECTED_PARALLELIZED_TEXT) | ||
})) | ||
}) | ||
}) | ||
|