-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathcompiler-path.ts
53 lines (48 loc) · 1.31 KB
/
compiler-path.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
// Copyright 2021 Google LLC. 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 * as p from 'path';
import {compilerModule} from './compiler-module';
/** The full command for the embedded compiler executable. */
export const compilerCommand = (() => {
try {
return [
require.resolve(
`${compilerModule}/dart-sass/src/dart` +
(process.platform === 'win32' ? '.exe' : ''),
),
require.resolve(`${compilerModule}/dart-sass/src/sass.snapshot`),
];
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
}
try {
return [
require.resolve(
`${compilerModule}/dart-sass/sass` +
(process.platform === 'win32' ? '.bat' : ''),
),
];
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
}
try {
return [
process.execPath,
p.join(p.dirname(require.resolve('sass')), 'sass.js'),
];
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
}
throw new Error(
"Embedded Dart Sass couldn't find the embedded compiler executable. " +
`Please make sure the optional dependency ${compilerModule} or sass is ` +
'installed in node_modules.',
);
})();