Skip to content

Commit

Permalink
Fail-over to copying files instead of linking
Browse files Browse the repository at this point in the history
This is slower - but required when running in VMs (like VirtualBox, VMware) using docker containers.  The docker containers don't allow hard links.  This is a similar technique as that which is used in broccoli-caching-writer.
  • Loading branch information
danlynn committed Jan 10, 2015
1 parent 136eeff commit 521d2c2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ Concat.prototype.write = function (readTree, destDir) {
var concatenatedOutputHash = crypto.createHash('md5').update(concatenatedOutput).digest('hex')
var cacheDir = self.getCacheDir()
if (concatenatedOutputHash === self.cachedConcatenatedOutputHash) {
fs.linkSync(path.join(cacheDir, "cached-output"), path.join(destDir, self.outputFile));
try {
fs.linkSync(path.join(cacheDir, "cached-output"), path.join(destDir, self.outputFile));
} catch (error) {
fs.writeFileSync(path.join(destDir, self.outputFile), fs.readFileSync(path.join(cacheDir, "cached-output")));
}
} else {
fs.writeFileSync(path.join(destDir, self.outputFile), concatenatedOutput)
fs.writeFileSync(path.join(cacheDir, "cached-output"), concatenatedOutput)
Expand Down

0 comments on commit 521d2c2

Please sign in to comment.