Skip to content

Commit 9657871

Browse files
committed
Make js a key of options
1 parent 1c2638b commit 9657871

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

tool/get-embedded-compiler.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,34 @@ import * as utils from './utils';
1414
*
1515
* Can check out and build the source from a Git `ref` or build from the source
1616
* at `path`. By default, checks out the latest revision from GitHub.
17+
*
18+
* The embedded compiler will be built as dart aot snapshot by default, or pure
19+
* node js if the `js` option is `true`.
1720
*/
1821
export async function getEmbeddedCompiler(
19-
js?: boolean,
20-
options?: {ref: string} | {path: string},
22+
options?:
23+
| {
24+
ref?: string;
25+
js?: boolean;
26+
}
27+
| {
28+
path: string;
29+
js?: boolean;
30+
},
2131
): Promise<void> {
32+
const js = options?.js ?? false;
2233
const repo = 'dart-sass';
2334

2435
let source: string;
25-
if (!options || 'ref' in options) {
36+
if (options !== undefined && 'path' in options) {
37+
source = options.path;
38+
} else {
2639
utils.fetchRepo({
2740
repo,
2841
outPath: 'build',
2942
ref: options?.ref ?? 'main',
3043
});
3144
source = p.join('build', repo);
32-
} else {
33-
source = options.path;
3445
}
3546

3647
// Make sure the compiler sees the same version of the language repo that the
@@ -43,7 +54,7 @@ export async function getEmbeddedCompiler(
4354
await utils.link(languageInHost, languageInCompiler);
4455
}
4556

46-
buildDartSassEmbedded(source, js ?? false);
57+
buildDartSassEmbedded(source, js);
4758

4859
const jsModulePath = p.resolve('node_modules/sass');
4960
const dartModulePath = p.resolve(p.join('node_modules', compilerModule));

tool/init.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ void (async () => {
5959

6060
if (!argv['skip-compiler']) {
6161
if (argv['compiler-ref']) {
62-
await getEmbeddedCompiler(argv['compiler-js'], {
62+
await getEmbeddedCompiler({
6363
ref: argv['compiler-ref'],
64+
js: argv['compiler-js'],
6465
});
6566
} else if (argv['compiler-path']) {
66-
await getEmbeddedCompiler(argv['compiler-js'], {
67+
await getEmbeddedCompiler({
6768
path: argv['compiler-path'],
69+
js: argv['compiler-js'],
6870
});
6971
} else {
70-
await getEmbeddedCompiler(argv['compiler-js']);
72+
await getEmbeddedCompiler({
73+
js: argv['compiler-js'],
74+
});
7175
}
7276
}
7377

0 commit comments

Comments
 (0)