@@ -29,6 +29,7 @@ void main(List<String> args) {
29
29
pkg.chocolateyNuspec.value = _nuspec;
30
30
pkg.homebrewRepo.value = "sass/homebrew-sass" ;
31
31
pkg.homebrewFormula.value = "Formula/sass.rb" ;
32
+ pkg.homebrewEditFormula.value = _updateHomebrewLanguageRevision;
32
33
pkg.jsRequires.value = [
33
34
pkg.JSRequire ("immutable" , target: pkg.JSRequireTarget .all),
34
35
pkg.JSRequire ("chokidar" , target: pkg.JSRequireTarget .cli),
@@ -292,3 +293,30 @@ function defaultExportDeprecation() {
292
293
293
294
File ("build/npm/sass.node.mjs" ).writeAsStringSync (buffer.toString ());
294
295
}
296
+
297
+ /// A regular expression to locate the language repo revision in the Dart Sass
298
+ /// Homebrew formula.
299
+ final _homebrewLanguageRegExp = RegExp (
300
+ r'resource "language" do$'
301
+ r'(?:(?! end$).)+'
302
+ r'revision: "([a-f0-9]{40})"' ,
303
+ dotAll: true ,
304
+ multiLine: true );
305
+
306
+ /// Updates the Homebrew [formula] to change the revision of the language repo
307
+ /// to the latest revision.
308
+ String _updateHomebrewLanguageRevision (String formula) {
309
+ var languageRepoRevision = run ("git" ,
310
+ arguments: ["ls-remote" , "https://github.com/sass/sass" ], quiet: true )
311
+ .split ("\t " )
312
+ .first;
313
+
314
+ var match = _homebrewLanguageRegExp.firstMatch (formula);
315
+ if (match == null ) {
316
+ fail ("Couldn't find a language repo revision in the Homebrew formula." );
317
+ }
318
+
319
+ return formula.substring (0 , match.start) +
320
+ match.group (0 )! .replaceFirst (match.group (1 )! , languageRepoRevision) +
321
+ formula.substring (match.end);
322
+ }
0 commit comments