add an optimisation pass for the cached output files

This commit is contained in:
Brian Gough
2015-02-24 15:48:34 +00:00
parent 67bfeacab8
commit 163a33674b
2 changed files with 36 additions and 1 deletions

View File

@@ -5,12 +5,16 @@ Path = require "path"
logger = require "logger-sharelatex"
_ = require "underscore"
OutputFileOptimiser = require "./OutputFileOptimiser"
module.exports = OutputCacheManager =
CACHE_DIR: '.cache/clsi'
saveOutputFiles: (outputFiles, target, callback) ->
# make a target/build_id directory and
# copy all the output files into it
#
# TODO: use Path module
buildId = 'build-' + Date.now()
relDir = OutputCacheManager.CACHE_DIR + '/' + buildId
newDir = target + '/' + relDir
@@ -31,7 +35,8 @@ module.exports = OutputCacheManager =
else if stats.isFile()
#console.log 'isFile: copying'
fse.copy src, dst, (err) ->
cb(err, newFile)
OutputFileOptimiser.optimiseFile src, dst, (err, result) ->
cb(err, newFile)
else
# other filetype - shouldn't happen
cb(new Error("output file is not a file"), file)