broccoli-caching-writer
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -0,2 +1,27 @@ | ||
## 0.5.1 | ||
* Allow easy inheritance. In your package's `index.js`: | ||
```javascript | ||
var CachingWriter = require('broccoli-caching-writer'); | ||
module.exports = CachingWriter.extend({ | ||
init: function(inputTrees, options) { | ||
/* do additional setup here */ | ||
}, | ||
updateCache: function(srcPaths, destDir) { | ||
/* do main processing */ | ||
} | ||
}); | ||
``` | ||
Then in a consuming Brocfile: | ||
```javascript | ||
var MyFoo = require('my-foo'); // package from above | ||
var tree = new MyFoo([someInput], { some: 'options' }); | ||
``` | ||
## 0.5.0 | ||
@@ -3,0 +28,0 @@ |
@@ -10,2 +10,3 @@ var fs = require('fs'); | ||
var generateRandomString = require('./lib/generate-random-string'); | ||
var CoreObject = require("core-object"); | ||
@@ -58,2 +59,3 @@ function CachingWriter (inputTrees, options) { | ||
}; | ||
CachingWriter.__proto__ = CoreObject; | ||
CachingWriter.prototype.constructor = CachingWriter; | ||
@@ -60,0 +62,0 @@ |
{ | ||
"name": "broccoli-caching-writer", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Broccoli plugin that allows simple caching (while still allowing N:N) based on the input tree hash.", | ||
@@ -21,2 +21,3 @@ "main": "index.js", | ||
"broccoli-kitchen-sink-helpers": "^0.2.5", | ||
"core-object": "0.0.2", | ||
"promise-map-series": "^0.2.0", | ||
@@ -23,0 +24,0 @@ "quick-temp": "^0.1.2", |
@@ -57,3 +57,33 @@ # Broccoli Caching Writer | ||
## Inheritance | ||
broccoli-caching-writer inherits from [core-object](https://github.com/stefanpenner/core-object) to allow super simple | ||
inheritance. You can still absolutely use the standard prototypal inheritance, but as you can see below there may be no | ||
need. | ||
Make an `index.js` for your package: | ||
```javascript | ||
var CachingWriter = require('broccoli-caching-writer'); | ||
module.exports = CachingWriter.extend({ | ||
init: function(inputTrees, options) { | ||
/* do additional setup here */ | ||
}, | ||
updateCache: function(srcPaths, destDir) { | ||
/* do main processing */ | ||
} | ||
}); | ||
``` | ||
Then in a consuming Brocfile: | ||
```javascript | ||
var MyFoo = require('my-foo'); // package from above | ||
var tree = new MyFoo([someInput], { some: 'options' }); | ||
``` | ||
## ZOMG!!! TESTS?!?!!? | ||
@@ -60,0 +90,0 @@ |
@@ -368,2 +368,34 @@ 'use strict'; | ||
}); | ||
describe('extend', function() { | ||
it('sets the methods correctly', function() { | ||
var TestPlugin = cachingWriter.extend({ | ||
foo: function() {} | ||
}); | ||
expect(TestPlugin).to.be.a(Function); | ||
expect(TestPlugin.prototype.foo).to.be.a(Function); | ||
}); | ||
it('calls CachingWriter constructor', function () { | ||
var MyPlugin = cachingWriter.extend({}); | ||
var instance = new MyPlugin("foo"); | ||
expect(instance.inputTrees).to.eql(["foo"]); | ||
}); | ||
it('can write files to destDir, and they will be in the final output', function(){ | ||
var TestWriter = cachingWriter.extend({ | ||
updateCache: function(srcDir, destDir) { | ||
fs.writeFileSync(destDir + '/something-cooler.js', 'whoa', {encoding: 'utf8'}); | ||
} | ||
}); | ||
var tree = new TestWriter(sourcePath); | ||
builder = new broccoli.Builder(tree); | ||
return builder.build().then(function(result) { | ||
var dir = result.directory; | ||
expect(fs.readFileSync(dir + '/something-cooler.js', {encoding: 'utf8'})).to.eql('whoa'); | ||
}); | ||
}); | ||
}); | ||
}); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
26726
522
102
0
7
+ Addedcore-object@0.0.2
+ Addedcore-object@0.0.2(transitive)
+ Addedlodash-node@2.4.1(transitive)