diff --git a/pipeline/compilers/__init__.py b/pipeline/compilers/__init__.py index eb43157e..7e6a2a5f 100644 --- a/pipeline/compilers/__init__.py +++ b/pipeline/compilers/__init__.py @@ -8,6 +8,7 @@ from django.contrib.staticfiles import finders from django.contrib.staticfiles.storage import staticfiles_storage from django.core.files.base import ContentFile +from django.core.files.storage import FileSystemStorage from django.utils.encoding import smart_bytes from django.utils.six import string_types, text_type @@ -41,8 +42,10 @@ def _compile(input_path): compiler.compile_file(infile, outfile, outdated=outdated, force=force, **compiler_options) + output_path = compiler.output_path(input_path, compiler.output_extension) + compiler.sync_file(output_path, outfile) - return compiler.output_path(input_path, compiler.output_extension) + return output_path else: return input_path @@ -67,6 +70,14 @@ def match_file(self, filename): def compile_file(self, infile, outfile, outdated=False, force=False): raise NotImplementedError + def sync_file(self, path, filename): + if isinstance(self.storage, FileSystemStorage): + return + + with open(filename) as f: + print("Syncing '%s'" % filename) + self.save_file(path, f.read()) + def save_file(self, path, content): return self.storage.save(path, ContentFile(smart_bytes(content))) diff --git a/tests/tests/test_compiler.py b/tests/tests/test_compiler.py index 5da06371..fd15490e 100644 --- a/tests/tests/test_compiler.py +++ b/tests/tests/test_compiler.py @@ -90,6 +90,8 @@ def match_file(self, path): def compile_file(self, infile, outfile, outdated=False, force=False): return + def sync_file(self, path, filename): + return @pipeline_settings(COMPILERS=['tests.tests.test_compiler.DummyCompiler']) class DummyCompilerTest(TestCase):