Commit a17312b2 by Timothée Peignier

don't compile if not outdated in development, but force compilation when running collectstatic

parent 0a7b5496
......@@ -23,13 +23,15 @@ class Compiler(object):
return [to_class(compiler) for compiler in settings.PIPELINE_COMPILERS]
compilers = property(compilers)
def compile(self, paths):
def compile(self, paths, force=False):
for index, path in enumerate(paths):
for compiler in self.compilers:
compiler = compiler(self.verbose)
if compiler.match_file(path):
new_path = self.output_path(path, compiler.output_extension)
paths[index] = new_path
if not force and not self.is_outdated(path, new_path):
continue
try:
content = self.read_file(path)
compiled_content = compiler.compile_file(content, finders.find(path))
......@@ -52,7 +54,7 @@ class Compiler(object):
def is_outdated(self, path, new_path):
try:
return self.storage.modified_time(path) > self.storage.modified_time(new_path)
except OSError:
except (OSError, NotImplementedError):
return True
def save_file(self, path, content):
......
......@@ -89,14 +89,14 @@ class Packager(object):
output_filename=package.output_filename,
variant=package.variant, **kwargs)
def compile(self, paths):
return self.compiler.compile(paths)
def compile(self, paths, force=False):
return self.compiler.compile(paths, force=force)
def pack(self, package, compress, signal, **kwargs):
output_filename = package.output_filename
if self.verbose:
print "Saving: %s" % output_filename
paths = self.compile(package.paths)
paths = self.compile(package.paths, force=True)
content = compress(paths, **kwargs)
self.save_file(output_filename, content)
signal.send(sender=self, package=package, **kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment