-
-
Notifications
You must be signed in to change notification settings - Fork 244
/
Copy pathpackage-config.js
108 lines (89 loc) · 4.3 KB
/
package-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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* @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("[package-config] it should have an ability to overwrite package's config:", () => {
before(() => process.chdir("test-workspace"))
after(() => process.chdir(".."))
beforeEach(removeResult)
it("Node API should address \"packageConfig\" option", async () => {
await nodeApi("test-task:package-config", { packageConfig: { "npm-run-all-test": { test: "OVERWRITTEN" } } })
assert(result() === "OVERWRITTEN")
})
it("Node API should address \"packageConfig\" option for multiple variables", async () => {
await nodeApi("test-task:package-config2", { packageConfig: { "npm-run-all-test": { test: "1", test2: "2", test3: "3" } } })
assert(result() === "1\n2\n3")
})
describe("CLI commands should address \"--a:b=c\" style options", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:package-config", "--npm-run-all-test:test=OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
it("run-s command", async () => {
await runSeq(["test-task:package-config", "--npm-run-all-test:test=OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
it("run-p command", async () => {
await runPar(["test-task:package-config", "--npm-run-all-test:test=OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
})
describe("CLI commands should address \"--a:b=c\" style options for multiple variables", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:package-config2", "--npm-run-all-test:test=1", "--npm-run-all-test:test2=2", "--npm-run-all-test:test3=3"])
assert(result() === "1\n2\n3")
})
it("run-s command", async () => {
await runSeq(["test-task:package-config2", "--npm-run-all-test:test=1", "--npm-run-all-test:test2=2", "--npm-run-all-test:test3=3"])
assert(result() === "1\n2\n3")
})
it("run-p command", async () => {
await runPar(["test-task:package-config2", "--npm-run-all-test:test=1", "--npm-run-all-test:test2=2", "--npm-run-all-test:test3=3"])
assert(result() === "1\n2\n3")
})
})
describe("CLI commands should address \"--a:b c\" style options", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
it("run-s command", async () => {
await runSeq(["test-task:package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
it("run-p command", async () => {
await runPar(["test-task:package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
})
describe("CLI commands should transfar overriting nested commands.", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:nested-package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
it("run-s command", async () => {
await runSeq(["test-task:nested-package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
it("run-p command", async () => {
await runPar(["test-task:nested-package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
})
})