Skip to content

Commit 574e1b0

Browse files
committed
feat: Update source from aqua settings
1 parent c2bf1de commit 574e1b0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tools/sync-latest-sass.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
import re
23
from pathlib import Path
34

45
import yaml
@@ -7,6 +8,15 @@
78

89
root = 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

1121
def 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+
1845
def 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

0 commit comments

Comments
 (0)