broccoli-persistent-filter
Advanced tools
Comparing version 1.1.4 to 1.1.5
30
index.js
@@ -86,6 +86,5 @@ 'use strict'; | ||
case 'change': | ||
fs.unlinkSync(outputFilePath); | ||
return this._handleFile(relativePath, srcDir, destDir, entry, outputFilePath); | ||
return this._handleFile(relativePath, srcDir, destDir, entry, outputFilePath, true); | ||
case 'create': | ||
return this._handleFile(relativePath, srcDir, destDir, entry, outputFilePath); | ||
return this._handleFile(relativePath, srcDir, destDir, entry, outputFilePath, false); | ||
} | ||
@@ -95,6 +94,9 @@ }, this); | ||
Filter.prototype._handleFile = function(relativePath, srcDir, destDir, entry, outputPath) { | ||
Filter.prototype._handleFile = function(relativePath, srcDir, destDir, entry, outputPath, isChange) { | ||
if (this.canProcessFile(relativePath)) { | ||
return this.processAndCacheFile(srcDir, destDir, entry); | ||
return this.processAndCacheFile(srcDir, destDir, entry, isChange); | ||
} else { | ||
if (isChange) { | ||
fs.unlinkSync(outputPath); | ||
} | ||
var srcPath = srcDir + '/' + relativePath; | ||
@@ -163,3 +165,3 @@ return symlinkOrCopySync(srcPath, outputPath); | ||
Filter.prototype.processAndCacheFile = function(srcDir, destDir, entry) { | ||
Filter.prototype.processAndCacheFile = function(srcDir, destDir, entry, isChange) { | ||
var filter = this; | ||
@@ -170,3 +172,3 @@ var relativePath = entry.relativePath; | ||
then(function asyncProcessFile() { | ||
return filter.processFile(srcDir, destDir, relativePath); | ||
return filter.processFile(srcDir, destDir, relativePath, isChange); | ||
}). | ||
@@ -191,3 +193,3 @@ then(undefined, | ||
Filter.prototype.processFile = function(srcDir, destDir, relativePath) { | ||
Filter.prototype.processFile = function(srcDir, destDir, relativePath, isChange) { | ||
var filter = this; | ||
@@ -218,2 +220,12 @@ var inputEncoding = this.inputEncoding; | ||
if (isChange) { | ||
var isSame = fs.readFileSync(outputPath, 'UTF-8') === outputString; | ||
if (isSame) { | ||
this._debug('[change:%s] but was the same, skipping', relativePath, isSame); | ||
return; | ||
} else { | ||
this._debug('[change:%s] but was NOT the same, writing new file', relativePath); | ||
} | ||
} | ||
try { | ||
@@ -233,3 +245,3 @@ fs.writeFileSync(outputPath, outputString, { | ||
return outputString; | ||
}); | ||
}.bind(this)); | ||
}; | ||
@@ -236,0 +248,0 @@ |
{ | ||
"name": "broccoli-persistent-filter", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "broccoli filter but with a persistent cache", | ||
@@ -57,4 +57,5 @@ "author": "Stefan Penner <stefan.penner@gmail.com>", | ||
"rimraf": "^2.4.2", | ||
"sinon": "^1.15.3" | ||
"sinon": "^1.15.3", | ||
"sinon-chai": "^2.8.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18247
262
11