/
cli.js
118 lines (118 loc) · 3.11 KB
/
cli.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
109
110
111
112
113
114
115
116
117
118
[
{
args: ["run", "test/fixtures/ts-interop/interop.ts"],
expect: { code: 0 }
},
{
args: ["run", "test/fixtures/interop-test.mjs"],
expect: { code: 0 }
},
{
args: ["run", "test/integration/test.ts"],
expect: { code: 0 }
},
{
args: ["build", "test/integration/type-module/main.js", "-", "tmp"],
expect: { code: 0 }
},
{
args: ["build", "test/integration/test.ts", "-o", "tmp"],
expect (code, stdout, stderr) {
return stdout.toString().indexOf('tmp/index.js') !== -1;
}
},
{
args: ["run", "--v8-cache", "test/integration/test.ts"],
expect: { code: 0 }
},
{
args: ["run", "--v8-cache", "test/integration/stack-trace.js"],
expect: { code: 0 }
},
{
args: ["run", "test/fixtures/error.js"],
expect: { code: 1 }
},
{
args: ["run", "test/fixtures/does-not-exist.js"],
expect: { code: 1 }
},
{
args: ["run", "test/fixtures/error.js", "--no-source-map-register"],
expect (code, stdout, stderr) {
return code === 1 && stderr.toString().indexOf('fixtures/error.js') === -1;
}
},
{
args: ["run", "--watch", "test/integration/test.ts"],
expect: { code: 2 }
},
{
args: ["build", "-o", "tmp", "--watch", "test/fixtures/no-dep.js"],
timeout: 500,
expect: { timeout: true }
},
{
args: ["run", "test/fixtures/ts-error1/fail.ts"],
expect (code, stdout, stderr) {
return code === 1 && stderr.toString().indexOf('fail.ts:2:1') !== -1;
}
},
{
args: ["run", "test/fixtures/ts-error2/ts-error.ts"],
expect (code, stdout, stderr) {
return code === 1 && stderr.toString().indexOf('ts-error.ts(3,16)') !== -1 && stderr.toString().split('\n').length < 11;
}
},
{
args: ["run", "-t", "test/fixtures/with-type-errors/ts-error.ts"],
expect: { code: 0 }
},
{
args: ["build", "-o", "tmp", "test/fixtures/test.cjs"],
expect (code, stdout, stderr) {
return stdout.toString().indexOf('tmp/index.cjs') !== -1;
}
},
{
args: ["build", "-o", "tmp", "test/fixtures/test.mjs"],
expect (code, stdout, stderr) {
return stdout.toString().indexOf('tmp/index.mjs') !== -1;
}
},
{
args: ["build", "-o", "tmp", "test/fixtures/test.mjs", "--stats-out", "tmp/stats.json"],
expect (code, stdout, stderr) {
const fs = require('fs');
try {
JSON.parse(fs.readFileSync('tmp/stats.json', 'utf8'));
} catch {
return false;
}
return true;
}
},
{
args: ["build", "--quiet", "test/integration/test.ts"],
expect (code, stdout) {
stdout = stdout.toString().replace(/[\r\n\s]/g, '').trim();
return stdout.length === 0;
}
},
{
args: ["build", "test/integration/test.ts"],
env: {
TYPESCRIPT_LOOKUP_PATH: '/tmp/nowhere'
},
expect (code, stdout) {
return code === 0 && stdout.indexOf('ncc built-in') !== -1;
},
},
{
args: ["build", "-o", "tmp", "test/fixtures/module.cjs"],
expect (code, stdout) {
const fs = require('fs');
return code === 0 && fs.readFileSync('tmp/index.js', 'utf8').toString().indexOf('export {') === -1;
}
}
]