7from pathlib import Path
10PURESCRIPT_PATH = Path("test/resources/purescript")
11SOURCE_PATH = PURESCRIPT_PATH / "src"
12OUTPUT_PATH = PURESCRIPT_PATH / "output"
13SCHEME_PATH = Path("test/resources/scheme")
14MODULE_REGEX = re.compile("\s*module\s+([\w\.]+)", re.MULTILINE)
17def run(cmd: list[str], path: str, env=None):
20 subprocess.run(cmd, env=env)
24def get_source_files(base_path: Path) -> list[Path]:
25 return Path(base_path).glob("**/*.purs")
28def read_module_name(path: Path) -> str:
29 text = path.read_text()
30 match = MODULE_REGEX.match(text)
34def copy_module(output_path: Path, scheme_path: Path, module_name: str):
35 from_file = output_path / module_name / "lib.sls"
36 to_dir = scheme_path / module_name
37 to_file = to_dir / "lib.sls"
38 os.makedirs(to_dir, exist_ok=True)
39 print(f"{from_file} -> {to_file}")
40 shutil.copy2(from_file, to_file)
43if __name__ == "__main__":
44 run(["stack", "install", "--fast", "--local-bin-path", "/tmp"],
46 run(["spago", "build"],
48 {'PATH': "/tmp:" + os.environ["PATH"]})
50 files = get_source_files(SOURCE_PATH)
51 modules = [read_module_name(f) for f in files]
53 for module in modules:
54 copy_module(OUTPUT_PATH, SCHEME_PATH, module)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list