-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a32ca2f
commit 09507bc
Showing
9 changed files
with
154 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"use strict" | ||
|
||
var appendResult = require("./lib/util").appendResult | ||
appendResult(String(process.env.npm_config_test)) |
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,4 @@ | ||
"use strict" | ||
|
||
var appendResult = require("./lib/util").appendResult | ||
appendResult(process.env.npm_config_test + "\n" + process.env.npm_config_test2 + "\n" + process.env.npm_config_test3) |
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,113 @@ | ||
/** | ||
* @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 {result, removeResult} = require("./lib/util") | ||
|
||
// Test targets. | ||
const nodeApi = require("../src/lib") | ||
const runAll = require("../src/bin/npm-run-all") | ||
const runSeq = require("../src/bin/run-s") | ||
const runPar = require("../src/bin/run-p") | ||
|
||
//------------------------------------------------------------------------------ | ||
// Test | ||
//------------------------------------------------------------------------------ | ||
|
||
describe("[config] it should have an ability to set config variables:", () => { | ||
before(() => process.chdir("test-workspace")) | ||
after(() => process.chdir("..")) | ||
|
||
beforeEach(removeResult) | ||
|
||
it("Node API should address \"config\" option", () => | ||
nodeApi("test-task:config", {config: {test: "this is a config"}}) | ||
.then(() => { | ||
assert(result() === "this is a config") | ||
}) | ||
) | ||
|
||
it("Node API should address \"config\" option for multiple variables", () => | ||
nodeApi("test-task:config2", {config: {test: "1", test2: "2", test3: "3"}}) | ||
.then(() => { | ||
assert(result() === "1\n2\n3") | ||
}) | ||
) | ||
|
||
describe("CLI commands should address \"--a=b\" style options", () => { | ||
it("npm-run-all command", () => | ||
runAll(["test-task:config", "--test=GO"]) | ||
.then(() => { | ||
assert(result() === "GO") | ||
}) | ||
) | ||
|
||
it("run-s command", () => | ||
runSeq(["test-task:config", "--test=GO"]) | ||
.then(() => { | ||
assert(result() === "GO") | ||
}) | ||
) | ||
|
||
it("run-p command", () => | ||
runPar(["test-task:config", "--test=GO"]) | ||
.then(() => { | ||
assert(result() === "GO") | ||
}) | ||
) | ||
}) | ||
|
||
describe("CLI commands should address \"--b=c\" style options for multiple variables", () => { | ||
it("npm-run-all command", () => | ||
runAll(["test-task:config2", "--test=1", "--test2=2", "--test3=3"]) | ||
.then(() => { | ||
assert(result() === "1\n2\n3") | ||
}) | ||
) | ||
|
||
it("run-s command", () => | ||
runSeq(["test-task:config2", "--test=1", "--test2=2", "--test3=3"]) | ||
.then(() => { | ||
assert(result() === "1\n2\n3") | ||
}) | ||
) | ||
|
||
it("run-p command", () => | ||
runPar(["test-task:config2", "--test=1", "--test2=2", "--test3=3"]) | ||
.then(() => { | ||
assert(result() === "1\n2\n3") | ||
}) | ||
) | ||
}) | ||
|
||
describe("CLI commands should transfar configs to nested commands.", () => { | ||
it("npm-run-all command", () => | ||
runAll(["test-task:nested-config", "--test=GO DEEP"]) | ||
.then(() => { | ||
assert(result() === "GO DEEP") | ||
}) | ||
) | ||
|
||
it("run-s command", () => | ||
runSeq(["test-task:nested-config", "--test=GO DEEP"]) | ||
.then(() => { | ||
assert(result() === "GO DEEP") | ||
}) | ||
) | ||
|
||
it("run-p command", () => | ||
runPar(["test-task:nested-config", "--test=GO DEEP"]) | ||
.then(() => { | ||
assert(result() === "GO DEEP") | ||
}) | ||
) | ||
}) | ||
}) |