forked from mysticatea/npm-run-all
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
91 lines (75 loc) · 3.13 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* @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 util = require("./lib/util")
const result = util.result
const removeResult = util.removeResult
const runAll = util.runAll
const runPar = util.runPar
const runSeq = util.runSeq
//------------------------------------------------------------------------------
// 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", async () => {
await nodeApi("test-task:config", { config: { test: "this is a config" } })
assert(result() === "this is a config")
})
it("Node API should address \"config\" option for multiple variables", async () => {
await nodeApi("test-task:config2", { config: { test: "1", test2: "2", test3: "3" } })
assert(result() === "1\n2\n3")
})
describe("CLI commands should address \"--a=b\" style options", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:config", "--test=GO"])
assert(result() === "GO")
})
it("run-s command", async () => {
await runSeq(["test-task:config", "--test=GO"])
assert(result() === "GO")
})
it("run-p command", async () => {
await runPar(["test-task:config", "--test=GO"])
assert(result() === "GO")
})
})
describe("CLI commands should address \"--b=c\" style options for multiple variables", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:config2", "--test=1", "--test2=2", "--test3=3"])
assert(result() === "1\n2\n3")
})
it("run-s command", async () => {
await runSeq(["test-task:config2", "--test=1", "--test2=2", "--test3=3"])
assert(result() === "1\n2\n3")
})
it("run-p command", async () => {
await runPar(["test-task:config2", "--test=1", "--test2=2", "--test3=3"])
assert(result() === "1\n2\n3")
})
})
describe("CLI commands should transfar configs to nested commands.", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:nested-config", "--test=GO DEEP"])
assert(result() === "GO DEEP")
})
it("run-s command", async () => {
await runSeq(["test-task:nested-config", "--test=GO DEEP"])
assert(result() === "GO DEEP")
})
it("run-p command", async () => {
await runPar(["test-task:nested-config", "--test=GO DEEP"])
assert(result() === "GO DEEP")
})
})
})