broccoli-caching-writer
Advanced tools
Comparing version 0.5.3 to 0.5.4
@@ -0,1 +1,5 @@ | ||
## 0.5.4 | ||
* Update to newer core-object version. | ||
## 0.5.3 | ||
@@ -2,0 +6,0 @@ |
54
index.js
@@ -6,11 +6,13 @@ var fs = require('fs'); | ||
var mapSeries = require('promise-map-series'); | ||
var quickTemp = require('quick-temp') | ||
var quickTemp = require('quick-temp'); | ||
var helpers = require('broccoli-kitchen-sink-helpers'); | ||
var symlinkOrCopy = require('symlink-or-copy'); | ||
var generateRandomString = require('./lib/generate-random-string'); | ||
var assign = require('lodash-node/modern/objects/assign'); | ||
var CoreObject = require('core-object'); | ||
function CachingWriter (inputTrees, options) { | ||
if (!(this instanceof CachingWriter)) return new CachingWriter(inputTrees, options); | ||
var proto = {}; | ||
proto.init = function(inputTrees, options) { | ||
this._inputTreeCacheHash = []; | ||
@@ -52,23 +54,21 @@ this._shouldBeIgnoredCache = Object.create(null); | ||
if (!Array.isArray(this.filterFromCache.include)) { | ||
throw new Error('Invalid filterFromCache.include option, it must be an array or undefined.') | ||
throw new Error('Invalid filterFromCache.include option, it must be an array or undefined.'); | ||
} | ||
if (!Array.isArray(this.filterFromCache.exclude)) { | ||
throw new Error('Invalid filterFromCache.exclude option, it must be an array or undefined.') | ||
throw new Error('Invalid filterFromCache.exclude option, it must be an array or undefined.'); | ||
} | ||
}; | ||
CachingWriter.__proto__ = CoreObject; | ||
CachingWriter.prototype.constructor = CachingWriter; | ||
CachingWriter.prototype.enforceSingleInputTree = false; | ||
proto.enforceSingleInputTree = false; | ||
CachingWriter.prototype.getCacheDir = function () { | ||
proto.getCacheDir = function () { | ||
return quickTemp.makeOrReuse(this, 'tmpCacheDir'); | ||
}; | ||
CachingWriter.prototype.getCleanCacheDir = function () { | ||
proto.getCleanCacheDir = function () { | ||
return quickTemp.makeOrRemake(this, 'tmpCacheDir'); | ||
}; | ||
CachingWriter.prototype.read = function (readTree) { | ||
proto.read = function (readTree) { | ||
var self = this; | ||
@@ -112,3 +112,3 @@ | ||
CachingWriter.prototype.cleanup = function () { | ||
proto.cleanup = function () { | ||
quickTemp.remove(this, 'tmpCacheDir'); | ||
@@ -122,3 +122,3 @@ | ||
CachingWriter.prototype.updateCache = function (srcDir, destDir) { | ||
proto.updateCache = function (srcDir, destDir) { | ||
throw new Error('You must implement updateCache.'); | ||
@@ -130,3 +130,3 @@ }; | ||
// one include pattern. | ||
CachingWriter.prototype.shouldBeIgnored = function (fullPath) { | ||
proto.shouldBeIgnored = function (fullPath) { | ||
if (this._shouldBeIgnoredCache[fullPath] !== undefined) { | ||
@@ -144,3 +144,3 @@ return this._shouldBeIgnoredCache[fullPath]; | ||
if (excludePatterns[i].test(fullPath) === true) { | ||
return this._shouldBeIgnoredCache[fullPath] = true; | ||
return (this._shouldBeIgnoredCache[fullPath] = true); | ||
} | ||
@@ -155,3 +155,3 @@ } | ||
if (includePatterns[i].test(fullPath) === true) { | ||
return this._shouldBeIgnoredCache[fullPath] = false; | ||
return (this._shouldBeIgnoredCache[fullPath] = false); | ||
} | ||
@@ -161,11 +161,11 @@ } | ||
// If no include patterns were matched, ignore this file. | ||
return this._shouldBeIgnoredCache[fullPath] = true; | ||
return (this._shouldBeIgnoredCache[fullPath] = true); | ||
} | ||
// Otherwise, don't ignore this file | ||
return this._shouldBeIgnoredCache[fullPath] = false; | ||
} | ||
return (this._shouldBeIgnoredCache[fullPath] = false); | ||
}; | ||
CachingWriter.prototype.keysForTree = function (fullPath, initialRelativePath) { | ||
proto.keysForTree = function (fullPath, initialRelativePath) { | ||
var relativePath = initialRelativePath || '.'; | ||
@@ -199,3 +199,3 @@ var stats; | ||
} | ||
if (entries != null) { | ||
if (entries) { | ||
for (var i = 0; i < entries.length; i++) { | ||
@@ -221,4 +221,16 @@ | ||
.concat(childKeys); | ||
}; | ||
function CachingWriter (inputTrees, options) { | ||
if (!(this instanceof CachingWriter)) return new CachingWriter(inputTrees, options); | ||
CoreObject.apply(this, arguments); | ||
if (this.init) { | ||
this.init.apply(this, arguments); | ||
} | ||
} | ||
CachingWriter.__proto__ = CoreObject; | ||
CachingWriter.prototype = Object.create(CoreObject.prototype); | ||
assign(CachingWriter.prototype, proto); | ||
module.exports = CachingWriter; |
{ | ||
"name": "broccoli-caching-writer", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "Broccoli plugin that allows simple caching (while still allowing N:N) based on the input tree hash.", | ||
@@ -21,3 +21,4 @@ "main": "index.js", | ||
"broccoli-kitchen-sink-helpers": "^0.2.5", | ||
"core-object": "0.0.2", | ||
"core-object": "0.0.3", | ||
"lodash-node": "^2.4.1", | ||
"promise-map-series": "^0.2.0", | ||
@@ -24,0 +25,0 @@ "quick-temp": "^0.1.2", |
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
27220
533
8
+ Addedlodash-node@^2.4.1
+ Addedcore-object@0.0.3(transitive)
- Removedcore-object@0.0.2(transitive)
Updatedcore-object@0.0.3