broccoli-caching-writer
Advanced tools
Comparing version 0.3.0 to 0.3.1
21
index.js
var fs = require('fs'); | ||
var path = require('path'); | ||
var RSVP = require('rsvp'); | ||
var mkdirp = require('mkdirp') | ||
@@ -40,10 +41,18 @@ var walkSync = require('walk-sync'); | ||
if (inputTreeHash !== self._cacheHash) { | ||
self.updateCache(srcDir, self.getCleanCacheDir()); | ||
return RSVP.resolve() | ||
.then(function() { | ||
var updateCacheResult; | ||
self._cacheHash = inputTreeHash; | ||
self._cacheTreeKeys = inputTreeKeys; | ||
} | ||
if (inputTreeHash !== self._cacheHash) { | ||
updateCacheResult = self.updateCache(srcDir, self.getCleanCacheDir()); | ||
linkFromCache(self.getCacheDir(), destDir); | ||
self._cacheHash = inputTreeHash; | ||
self._cacheTreeKeys = inputTreeKeys; | ||
} | ||
return updateCacheResult; | ||
}) | ||
.finally(function() { | ||
linkFromCache(self.getCacheDir(), destDir); | ||
}); | ||
}) | ||
@@ -50,0 +59,0 @@ }; |
{ | ||
"name": "broccoli-caching-writer", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Broccoli plugin that allows simple caching (while still allowing N:N) based on the input tree hash.", | ||
@@ -24,3 +24,4 @@ "main": "index.js", | ||
"quick-temp": "~0.1.2", | ||
"walk-sync": "~0.1.2" | ||
"walk-sync": "~0.1.2", | ||
"rsvp": "~3.0.6" | ||
}, | ||
@@ -32,5 +33,4 @@ "devDependencies": { | ||
"expect.js": "~0.3.1", | ||
"mkdirp": "~0.4.0", | ||
"rsvp": "~3.0.6" | ||
"mkdirp": "~0.4.0" | ||
} | ||
} |
@@ -9,2 +9,4 @@ # Broccoli Caching Writer | ||
If you would prefer to preform your plugins work in a non-synchronous way, simply return a promise from `updateCache`. | ||
## ZOMG!!! TESTS?!?!!? | ||
@@ -11,0 +13,0 @@ |
@@ -125,3 +125,20 @@ 'use strict'; | ||
}); | ||
it('can return a promise that is resolved', function(){ | ||
var thenCalled = false; | ||
var tree = cachingWriter(sourcePath, { | ||
updateCache: function(srcDir, destDir) { | ||
return {then: function(callback) { | ||
thenCalled = true; | ||
callback(); | ||
}}; | ||
} | ||
}); | ||
builder = new broccoli.Builder(tree); | ||
return builder.build().then(function(dir) { | ||
expect(thenCalled).to.be.ok(); | ||
}); | ||
}); | ||
}); | ||
}); |
11514
5
259
25
6
+ Addedrsvp@~3.0.6
+ Addedrsvp@3.0.21(transitive)
- Removedrsvp@3.6.2(transitive)