forked from timreichen/Bundler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli_test.ts
118 lines (105 loc) · 3.28 KB
/
cli_test.ts
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
109
110
111
112
113
114
115
116
117
118
import { parsePaths } from "./_util.ts";
import { path } from "./deps.ts";
import { assertEquals } from "./test_deps.ts";
const root = "dist";
Deno.test({
name: "outputMap",
async fn(t) {
await t.step({
name: "relative input",
fn() {
const relativeInput = "src/index.html";
const input =
path.toFileUrl(path.resolve(Deno.cwd(), relativeInput)).href;
const args = [`${relativeInput}`];
assertEquals(parsePaths(args, root), {
inputs: [input],
outputMap: {},
});
},
});
await t.step({
name: "filepath input",
fn() {
const relativeInput = "src/index.html";
const input =
path.toFileUrl(path.resolve(Deno.cwd(), relativeInput)).href;
const args = [`${relativeInput}`];
assertEquals(parsePaths(args, root), {
inputs: [input],
outputMap: {},
});
},
});
await t.step({
name: "url input",
fn() {
const input = "https://deno.land/std/path/mod.ts";
const args = [`${input}`];
assertEquals(parsePaths(args, root), {
inputs: [input],
outputMap: {},
});
},
});
await t.step({
name: "relative input and relative output",
fn() {
const relativeInput = "src/index.html";
const relativeOutput = "index.html";
const input =
path.toFileUrl(path.resolve(Deno.cwd(), relativeInput)).href;
const output =
path.toFileUrl(path.resolve(Deno.cwd(), root, relativeOutput)).href;
const args = [`${relativeInput}=${relativeOutput}`];
assertEquals(parsePaths(args, root), {
inputs: [input],
outputMap: { [input]: output },
});
},
});
await t.step({
name: "absolute input and absolute output",
fn() {
const relativeInput = "src/index.html";
const relativeOutput = "index.html";
const input =
path.toFileUrl(path.resolve(Deno.cwd(), relativeInput)).href;
const output =
path.toFileUrl(path.resolve(Deno.cwd(), root, relativeOutput)).href;
const args = [`${input}=${output}`];
assertEquals(parsePaths(args, root), {
inputs: [input],
outputMap: { [input]: output },
});
},
});
await t.step({
name: "multiple inputs and outputs",
fn() {
const relativeInput1 = "src/index.html";
const relativeOutput1 = "index.html";
const input1 =
path.toFileUrl(path.resolve(Deno.cwd(), relativeInput1)).href;
const output1 =
path.toFileUrl(path.resolve(Deno.cwd(), root, relativeOutput1))
.href;
const relativeInput2 = "src/index.ts";
const relativeOutput2 = "index.ts";
const input2 =
path.toFileUrl(path.resolve(Deno.cwd(), relativeInput2)).href;
const output2 =
path.toFileUrl(path.resolve(Deno.cwd(), root, relativeOutput2))
.href;
const args = [
`${relativeInput1}=${output1}`,
`${input2}=${relativeOutput2}`,
];
assertEquals(parsePaths(args, root), {
inputs: [input1, input2],
outputMap: { [input1]: output1, [input2]: output2 },
});
},
});
},
});