Skip to content

Commit 8b380c6

Browse files
authored
Merge pull request #174 from sass/run-locally
Fix various CI issues
2 parents bba6a4f + 2225d27 commit 8b380c6

File tree

4 files changed

+40
-22
lines changed

4 files changed

+40
-22
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,20 @@ jobs:
7373
uses: sass/clone-linked-repo@v1
7474
with: {repo: sass/embedded-protocol, default-ref: null}
7575

76-
- name: Check out the embedded compiler
77-
uses: sass/clone-linked-repo@v1
78-
with: {repo: sass/dart-sass-embedded, default-ref: null}
79-
8076
- name: Check out Dart Sass
77+
id: clone-dart-sass
8178
uses: sass/clone-linked-repo@v1
8279
with: {repo: sass/dart-sass, default-ref: null}
8380

81+
- name: Check out the embedded compiler
82+
uses: sass/clone-linked-repo@v1
83+
with:
84+
repo: sass/dart-sass-embedded
85+
# If we check out a specific version of Dart Sass, always check out
86+
# the embedded compiler as well so we can actually use that Dart Sass
87+
# version.
88+
default-ref: ${{ !steps.clone-dart-sass.skip && 'main' || null }}
89+
8490
- name: Link the embedded compiler to Dart Sass
8591
run: |
8692
if [[ -d dart-sass ]]; then
@@ -135,14 +141,20 @@ jobs:
135141
uses: sass/clone-linked-repo@v1
136142
with: {repo: sass/embedded-protocol, default-ref: null}
137143

138-
- name: Check out the embedded compiler
139-
uses: sass/clone-linked-repo@v1
140-
with: {repo: sass/dart-sass-embedded, default-ref: null}
141-
142144
- name: Check out Dart Sass
145+
id: clone-dart-sass
143146
uses: sass/clone-linked-repo@v1
144147
with: {repo: sass/dart-sass, default-ref: null}
145148

149+
- name: Check out the embedded compiler
150+
uses: sass/clone-linked-repo@v1
151+
with:
152+
repo: sass/dart-sass-embedded
153+
# If we check out a specific version of Dart Sass, always check out
154+
# the embedded compiler as well so we can actually use that Dart Sass
155+
# version.
156+
default-ref: ${{ !steps.clone-dart-sass.skip && 'main' || null }}
157+
146158
- name: Link the embedded compiler to Dart Sass
147159
run: |
148160
if [[ -d dart-sass ]]; then

lib/src/compile.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ async function compileRequestAsync(
153153
): Promise<CompileResult> {
154154
const functions = new FunctionRegistry(options?.functions);
155155
const embeddedCompiler = new AsyncEmbeddedCompiler();
156+
embeddedCompiler.stderr$.subscribe(data => process.stderr.write(data));
156157

157158
try {
158159
const dispatcher = createDispatcher<'async'>(
@@ -198,6 +199,7 @@ function compileRequestSync(
198199
): CompileResult {
199200
const functions = new FunctionRegistry(options?.functions);
200201
const embeddedCompiler = new SyncEmbeddedCompiler();
202+
embeddedCompiler.stderr$.subscribe(data => process.stderr.write(data));
201203

202204
try {
203205
const dispatcher = createDispatcher<'sync'>(

lib/src/compiler-path.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ import {isErrnoException} from './utils';
88

99
/** The path to the embedded compiler executable. */
1010
export const compilerPath = (() => {
11-
try {
12-
return require.resolve(
13-
`sass-embedded-${process.platform}-${process.arch}/` +
14-
'dart-sass-embedded/dart-sass-embedded' +
15-
(process.platform === 'win32' ? '.bat' : '')
16-
);
17-
} catch (e: unknown) {
18-
if (!(isErrnoException(e) && e.code === 'MODULE_NOT_FOUND')) {
19-
throw e;
20-
}
21-
}
22-
2311
// find for development
2412
for (const path of ['vendor', '../../../lib/src/vendor']) {
2513
const executable = p.resolve(
@@ -33,6 +21,18 @@ export const compilerPath = (() => {
3321
if (fs.existsSync(executable)) return executable;
3422
}
3523

24+
try {
25+
return require.resolve(
26+
`sass-embedded-${process.platform}-${process.arch}/` +
27+
'dart-sass-embedded/dart-sass-embedded' +
28+
(process.platform === 'win32' ? '.bat' : '')
29+
);
30+
} catch (e: unknown) {
31+
if (!(isErrnoException(e) && e.code === 'MODULE_NOT_FOUND')) {
32+
throw e;
33+
}
34+
}
35+
3636
throw new Error(
3737
"Embedded Dart Sass couldn't find the embedded compiler executable. " +
3838
'Please make sure the optional dependency ' +

lib/src/sync-compiler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class SyncEmbeddedCompiler {
2121
/** The buffers emitted by the child process's stderr. */
2222
readonly stderr$ = new Subject<Buffer>();
2323

24+
/** Whether the underlying compiler has already exited. */
25+
private exited = false;
26+
2427
/** Writes `buffer` to the child process's stdin. */
2528
writeStdin(buffer: Buffer): void {
2629
this.process.stdin.write(buffer);
@@ -38,14 +41,15 @@ export class SyncEmbeddedCompiler {
3841
return true;
3942

4043
case 'exit':
44+
this.exited = true;
4145
return false;
4246
}
4347
}
4448

4549
/** Blocks until the underlying process exits. */
4650
yieldUntilExit(): void {
47-
while (this.yield()) {
48-
// Any events will be handled by `this.yield()`.
51+
while (!this.exited) {
52+
this.yield();
4953
}
5054
}
5155

0 commit comments

Comments
 (0)