Skip to content

Commit

Permalink
Prefer a local development compiler to an installed dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Dec 14, 2022
1 parent fec6ff6 commit 37ddc09
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/src/compiler-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ import {isErrnoException} from './utils';

/** The path to the embedded compiler executable. */
export const compilerPath = (() => {
try {
return require.resolve(
`sass-embedded-${process.platform}-${process.arch}/` +
'dart-sass-embedded/dart-sass-embedded' +
(process.platform === 'win32' ? '.bat' : '')
);
} catch (e: unknown) {
if (!(isErrnoException(e) && e.code === 'MODULE_NOT_FOUND')) {
throw e;
}
}

// find for development
for (const path of ['vendor', '../../../lib/src/vendor']) {
const executable = p.resolve(
Expand All @@ -33,6 +21,18 @@ export const compilerPath = (() => {
if (fs.existsSync(executable)) return executable;
}

try {
return require.resolve(
`sass-embedded-${process.platform}-${process.arch}/` +
'dart-sass-embedded/dart-sass-embedded' +
(process.platform === 'win32' ? '.bat' : '')
);
} catch (e: unknown) {
if (!(isErrnoException(e) && 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 ' +
Expand Down

0 comments on commit 37ddc09

Please sign in to comment.