use a separate function for hidden file check

This commit is contained in:
Brian Gough
2017-09-26 11:03:20 +01:00
parent dbeff9a7b8
commit 23fec68111

View File

@@ -64,7 +64,7 @@ module.exports = OutputCacheManager =
results = []
async.mapSeries outputFiles, (file, cb) ->
# don't send dot files as output, express doesn't serve them
if file?.path?.match(/^\.|\/./)
if OutputCacheManager._fileIsHidden(file.path)
logger.warn compileDir: compileDir, path: file.path, "ignoring dotfile in output"
return cb()
# copy other files into cache directory if valid
@@ -149,6 +149,9 @@ module.exports = OutputCacheManager =
removeDir dir, cb
, callback
_fileIsHidden: (path) ->
return path?.match(/^\.|\/./)?
_checkFileIsSafe: (src, callback = (error, isSafe) ->) ->
# check if we have a valid file to copy into the cache
fs.stat src, (err, stats) ->