@@ -8,6 +8,7 @@ import fetch from 'node-fetch';
8
8
import * as p from 'path' ;
9
9
import * as yaml from 'yaml' ;
10
10
import * as shell from 'shelljs' ;
11
+ import { simpleGit } from 'simple-git' ;
11
12
import { extract as extractTar } from 'tar' ;
12
13
13
14
import * as pkg from '../package.json' ;
@@ -85,7 +86,7 @@ export async function getEmbeddedProtocol(
85
86
) : Promise < void > {
86
87
const repo = 'embedded-protocol' ;
87
88
88
- options ??= defaultVersionOption ( 'protocol-version' ) ;
89
+ options ??= await defaultVersionOption ( 'protocol-version' ) ;
89
90
if ( 'version' in options ) {
90
91
const version = options ?. version ;
91
92
await downloadRelease ( {
@@ -108,7 +109,11 @@ export async function getEmbeddedProtocol(
108
109
const source =
109
110
options && 'path' in options ? options . path : p . join ( BUILD_PATH , repo ) ;
110
111
buildEmbeddedProtocol ( source ) ;
111
- await link ( 'build/embedded-protocol' , p . join ( outPath , repo ) ) ;
112
+
113
+ // Make the VERSION consistently accessible for the dependency test and any
114
+ // curious users.
115
+ await link ( p . join ( source , 'VERSION' ) , 'build/embedded-protocol-out/VERSION' ) ;
116
+ await link ( 'build/embedded-protocol-out' , p . join ( outPath , repo ) ) ;
112
117
}
113
118
114
119
/**
@@ -136,7 +141,7 @@ export async function getDartSassEmbedded(
136
141
}
137
142
) : Promise < void > {
138
143
const repo = 'dart-sass-embedded' ;
139
- options ??= defaultVersionOption ( 'compiler-version' ) ;
144
+ options ??= await defaultVersionOption ( 'compiler-version' ) ;
140
145
141
146
await checkForMusl ( ) ;
142
147
@@ -287,8 +292,7 @@ function fetchRepo(options: {
287
292
`git clone \
288
293
--depth=1 \
289
294
https://github.com/sass/${ options . repo } \
290
- ${ p . join ( options . outPath , options . repo ) } ` ,
291
- { silent : true }
295
+ ${ p . join ( options . outPath , options . repo ) } `
292
296
) ;
293
297
}
294
298
@@ -297,10 +301,7 @@ function fetchRepo(options: {
297
301
console . log ( `Fetching ${ version } for ${ options . repo } .` ) ;
298
302
shell . exec (
299
303
`git fetch --depth=1 origin ${ options . ref } && git reset --hard FETCH_HEAD` ,
300
- {
301
- silent : true ,
302
- cwd : p . join ( options . outPath , options . repo ) ,
303
- }
304
+ { cwd : p . join ( options . outPath , options . repo ) }
304
305
) ;
305
306
}
306
307
@@ -322,38 +323,38 @@ function buildEmbeddedProtocol(repoPath: string): void {
322
323
process . platform === 'win32'
323
324
? '%CD%/node_modules/.bin/protoc-gen-ts.cmd'
324
325
: 'node_modules/.bin/protoc-gen-ts' ;
325
- mkdirSync ( 'build/embedded-protocol' , { recursive : true } ) ;
326
+ mkdirSync ( 'build/embedded-protocol-out ' , { recursive : true } ) ;
326
327
shell . exec (
327
328
`${ protocPath } \
328
329
--plugin="protoc-gen-ts=${ pluginPath } " \
329
- --js_out="import_style=commonjs,binary:build/embedded-protocol" \
330
- --ts_out="build/embedded-protocol" \
330
+ --js_out="import_style=commonjs,binary:build/embedded-protocol-out " \
331
+ --ts_out="build/embedded-protocol-out " \
331
332
--proto_path="${ repoPath } " \
332
- ${ proto } ` ,
333
- { silent : true }
333
+ ${ proto } `
334
334
) ;
335
335
}
336
336
337
337
// Builds the Embedded Dart Sass executable from the source at `repoPath`.
338
338
function buildDartSassEmbedded ( repoPath : string ) : void {
339
339
console . log ( 'Downloading dart-sass-embedded dependencies.' ) ;
340
- shell . exec ( 'dart pub upgrade' , {
341
- cwd : repoPath ,
342
- silent : true ,
343
- } ) ;
340
+ shell . exec ( 'dart pub upgrade' , { cwd : repoPath } ) ;
344
341
345
342
console . log ( 'Building dart-sass-embedded executable.' ) ;
346
- shell . exec ( 'dart run grinder protobuf pkg-standalone-dev' , {
347
- cwd : repoPath ,
348
- silent : true ,
349
- } ) ;
343
+ shell . exec ( 'dart run grinder protobuf pkg-standalone-dev' , { cwd : repoPath } ) ;
350
344
}
351
345
352
346
// Given the name of a field in `package.json`, returns the default version
353
347
// option described by that field.
354
- function defaultVersionOption (
348
+ async function defaultVersionOption (
355
349
pkgField : keyof typeof pkg
356
- ) : { version : string } | { ref : string } {
350
+ ) : Promise < { version : string } | { ref : string } > {
351
+ // If we're on a feature branch, fetch the matching feature branch from the
352
+ // compiler.
353
+ if ( pkgField === 'compiler-version' ) {
354
+ const branch = ( await simpleGit ( ) . branch ( ) ) . current ;
355
+ if ( branch . startsWith ( 'feature.' ) ) return { ref : branch } ;
356
+ }
357
+
357
358
const version = pkg [ pkgField ] as string ;
358
359
return version . endsWith ( '-dev' ) ? { ref : 'main' } : { version} ;
359
360
}
0 commit comments