11from typing import List , Optional
2- from collections import ChainMap
2+ import os . path
33from pathlib import Path
4+ from collections import ChainMap
45import json
56from tempfile import TemporaryDirectory
67import subprocess
78
8- from dirsync import sync
99from doit .tools import create_folder , config_changed
1010
1111from elm_doc import elm_platform
@@ -39,8 +39,7 @@ def build_project_docs_json(
3939 json .dump (elm_project_with_exposed_modules , f )
4040
4141 package_src_dir = build_path / 'src'
42- for source_dir in project .source_directories :
43- sync (str (project .path / source_dir ), str (package_src_dir ), 'sync' , create = True )
42+ _sync_source_files (project , package_src_dir )
4443
4544 for elm_file_path in package_src_dir .glob ('**/*.elm' ):
4645 if elm_parser .is_port_module (elm_file_path ):
@@ -65,6 +64,23 @@ def _run_elm_make(elm_path: Path, output_path: Path, build_path: Path):
6564 )
6665
6766
67+ @capture_subprocess_error_as_task_failure
68+ def _sync_source_files (project : ElmProject , target_directory : Path ) -> None :
69+ '''Copy source files to a single directory. This meets the requirement of Elm
70+ that a package project can only have a single source directory and gives
71+ us an isolated environment so that Elm can run in parallel with any invocation
72+ of Elm within the actual project.
73+ '''
74+ target_directory .mkdir (parents = True , exist_ok = True )
75+ sources = ['{}/./' .format (os .path .normpath (source_dir ))
76+ for source_dir in project .source_directories ]
77+ subprocess .check_output (
78+ ['rsync' , '-a' , '--delete' , '--recursive' ] + sources + [str (target_directory )],
79+ cwd = str (project .path ),
80+ stderr = subprocess .STDOUT ,
81+ )
82+
83+
6884def create_main_project_tasks (
6985 project : ElmProject ,
7086 project_config : ProjectConfig ,
0 commit comments