-
Notifications
You must be signed in to change notification settings - Fork 27
/
init.ts
94 lines (87 loc) · 2.51 KB
/
init.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
// Copyright 2020 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
import yargs from 'yargs';
import {getEmbeddedCompiler} from './get-embedded-compiler';
import {getEmbeddedProtocol} from './get-embedded-protocol';
import {getJSApi} from './get-js-api';
const argv = yargs(process.argv.slice(2))
.option('compiler-path', {
type: 'string',
description:
'Build the Embedded Dart Sass binary from the source at this path.',
})
.option('compiler-ref', {
type: 'string',
description: 'Build the Embedded Dart Sass binary from this Git ref.',
})
.option('skip-compiler', {
type: 'boolean',
description: "Don't Embedded Dart Sass at all.",
})
.option('protocol-path', {
type: 'string',
description: 'Build the Embedded Protocol from the source at this path.',
})
.option('protocol-ref', {
type: 'string',
description: 'Build the Embedded Protocol from this Git ref.',
})
.option('api-path', {
type: 'string',
description: 'Use the JS API definitions from the source at this path.',
})
.option('api-ref', {
type: 'string',
description: 'Build the JS API definitions from this Git ref.',
})
.conflicts({
'compiler-path': ['compiler-ref', 'skip-compiler'],
'compiler-ref': ['skip-compiler'],
'protocol-path': ['protocol-ref'],
'api-path': 'api-ref',
})
.parseSync();
(async () => {
try {
const outPath = 'lib/src/vendor';
if (argv['protocol-ref']) {
await getEmbeddedProtocol(outPath, {
ref: argv['protocol-ref'],
});
} else if (argv['protocol-path']) {
await getEmbeddedProtocol(outPath, {
path: argv['protocol-path'],
});
} else {
await getEmbeddedProtocol(outPath);
}
if (!argv['skip-compiler']) {
if (argv['compiler-ref']) {
await getEmbeddedCompiler(outPath, {
ref: argv['compiler-ref'],
});
} else if (argv['compiler-path']) {
await getEmbeddedCompiler(outPath, {
path: argv['compiler-path'],
});
} else {
await getEmbeddedCompiler(outPath);
}
}
if (argv['api-ref']) {
await getJSApi(outPath, {
ref: argv['api-ref'],
});
} else if (argv['api-path']) {
await getJSApi(outPath, {
path: argv['api-path'],
});
} else {
await getJSApi(outPath);
}
} catch (error) {
console.error(error);
process.exitCode = 1;
}
})();