File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python
2+ import re
23from pathlib import Path
34
45import yaml
78
89root = Path (__file__ ).parents [1 ]
910
11+ TARGETS = {
12+ root / "src/sass_embedded/_const.py" : [
13+ {
14+ "match" : r'DART_SASS_VERSION = ".+"' ,
15+ "replace" : r'DART_SASS_VERSION = "{version}"' ,
16+ }
17+ ]
18+ }
19+
1020
1121def pick_sass_version (aqua : dict ):
1222 for pkg in aqua ["packages" ]:
@@ -15,6 +25,23 @@ def pick_sass_version(aqua: dict):
1525 raise Exception ("Package is not found" )
1626
1727
28+ def update_sources (version : str ):
29+ for src , rules in TARGETS .items ():
30+ lines = src .read_text ().split ("\n " )
31+ new_lines = []
32+ for idx , line in enumerate (lines ):
33+ if not line :
34+ new_lines .append (line )
35+ continue
36+ for rule in rules :
37+ if not re .fullmatch (rule ["match" ], line ):
38+ continue
39+ line = rule ["replace" ].format (version = version )
40+ else :
41+ new_lines .append (line )
42+ src .write_text ("\n " .join (new_lines ))
43+
44+
1845def main ():
1946 aqua_yaml_path = root / "aqua.yaml"
2047 aqua = yaml .safe_load (aqua_yaml_path .read_text ())
@@ -24,6 +51,7 @@ def main():
2451 if sass_version == const .DART_SASS_VERSION :
2552 return 0
2653 print ("Detect newer Dart Sass." )
54+ update_sources (sass_version )
2755 pass
2856
2957
You can’t perform that action at this time.
0 commit comments