broccoli-sprite
Advanced tools
Comparing version 0.0.7 to 0.1.0
72
index.js
var path = require('path'); | ||
var mkdirp = require('mkdirp'); | ||
var nodeSpriteGenerator = require('node-sprite-generator'); | ||
var brocWriter = require('broccoli-writer'); | ||
var brocCachingWriter = require('broccoli-caching-writer'); | ||
var rsvp = require('rsvp'); | ||
@@ -11,3 +11,3 @@ | ||
} | ||
this.inTree = inTree; | ||
this.inputTree = inTree; | ||
options = options || {}; | ||
@@ -23,3 +23,4 @@ this.options = {}; | ||
BroccoliSprite.prototype = Object.create(brocWriter.prototype); | ||
//Using broccoli caching writer to avoid recompiling the sprite sheets each time | ||
BroccoliSprite.prototype = Object.create(brocCachingWriter.prototype); | ||
BroccoliSprite.prototype.constructor = BroccoliSprite; | ||
@@ -29,43 +30,42 @@ BroccoliSprite.prototype.description = 'sprite'; | ||
if (this.options.debug) { | ||
console.log.apply(this, arguments); | ||
console.log.apply(null, arguments); | ||
} | ||
}; | ||
BroccoliSprite.prototype.write = function(readTree, destDir) { | ||
BroccoliSprite.prototype.updateCache = function(srcDir, destDir) { | ||
var self = this; | ||
self.debugLog('Running BroccoliSprite'); | ||
self.debugLog('Running BroccoliSprite updateCache'); | ||
return readTree(this.inTree).then(function (srcDir) { | ||
var files = (self.options.src || []).map(function(file) { | ||
return srcDir+'/'+file; | ||
var files = (self.options.src || []).map(function(file) { | ||
return srcDir+'/'+file; | ||
}); | ||
self.debugLog('srcDir', srcDir); | ||
self.debugLog('destDir', destDir); | ||
self.debugLog('files', files); | ||
var spritePath = path.join(destDir, self.options.spritePath); | ||
var stylesheetPath = path.join(destDir, self.options.stylesheetPath); | ||
mkdirp.sync(path.dirname(spritePath)); | ||
mkdirp.sync(path.dirname(stylesheetPath)); | ||
var nsgOptions = JSON.parse(JSON.stringify(self.options)); //lazy way to deep clone | ||
nsgOptions.src = files; | ||
nsgOptions.spritePath = spritePath; | ||
nsgOptions.stylesheetPath = stylesheetPath; | ||
self.debugLog('Options: ', nsgOptions); | ||
self.debugLog('spritePath', spritePath); | ||
self.debugLog('stylesheetPath', stylesheetPath); | ||
var promise = new rsvp.Promise(function(resolvePromise, rejectPromise) { | ||
nodeSpriteGenerator(nsgOptions, function (err) { | ||
if (!err) { | ||
self.debugLog('Sprite generated!'); | ||
resolvePromise(destDir); | ||
} | ||
else { | ||
self.debugLog('Sprite generation failed:', err); | ||
rejectPromise(err); | ||
} | ||
}); | ||
self.debugLog('srcDir', srcDir); | ||
self.debugLog('destDir', destDir); | ||
self.debugLog('files', files); | ||
var spritePath = path.join(destDir, self.options.spritePath); | ||
var stylesheetPath = path.join(destDir, self.options.stylesheetPath); | ||
mkdirp.sync(path.dirname(spritePath)); | ||
mkdirp.sync(path.dirname(stylesheetPath)); | ||
var nsgOptions = JSON.parse(JSON.stringify(self.options)); //lazy way to deep clone | ||
nsgOptions.src = files; | ||
nsgOptions.spritePath = spritePath; | ||
nsgOptions.stylesheetPath = stylesheetPath; | ||
self.debugLog('Options: ', nsgOptions); | ||
self.debugLog('spritePath', spritePath); | ||
self.debugLog('stylesheetPath', stylesheetPath); | ||
var promise = new rsvp.Promise(function(resolvePromise, rejectPromise) { | ||
nodeSpriteGenerator(nsgOptions, function (err) { | ||
if (!err) { | ||
self.debugLog('Sprite generated!'); | ||
resolvePromise(true); | ||
} | ||
else { | ||
console.log('Sprite generation failed:', err); | ||
rejectPromise(err); | ||
} | ||
}); | ||
}); | ||
return promise; | ||
}); | ||
return promise; | ||
}; | ||
module.exports = BroccoliSprite; |
{ | ||
"name": "broccoli-sprite", | ||
"version": "0.0.7", | ||
"version": "0.1.0", | ||
"description": "Broccoli plugin for CSS image sprite generation", | ||
@@ -37,6 +37,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"broccoli-caching-writer": "^0.4.2", | ||
"broccoli-concat": "0.0.6", | ||
"broccoli-merge-trees": "^0.1.4", | ||
"broccoli-static-compiler": "^0.1.4", | ||
"broccoli-writer": "~0.1.1", | ||
"lodash-node": "^2.4.1", | ||
@@ -43,0 +43,0 @@ "mkdirp": "~0.5.0", |
@@ -103,5 +103,15 @@ # A BroccoliJs plugin for sprite generation | ||
- Landed with [ember-sprite](https://github.com/bguiz/ember-sprite) | ||
- [x] Add caching to speed up incremental builds | ||
## Contributors | ||
Maintained by [bguiz](http://github.com/bguiz). | ||
Additional contributions from: | ||
- [Connorhd](http://github.com/Connorhd) | ||
- [harianus](http://github.com/harianus) | ||
## Licence | ||
[GPL v3](http://opensource.org/licenses/GPL-3.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
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
7770
117
0
62
+ Addedbroccoli-caching-writer@0.4.2(transitive)
+ Addedminimist@0.0.8(transitive)
+ Addedmkdirp@0.4.2(transitive)
+ Addedrsvp@3.0.21(transitive)
- Removedbroccoli-writer@~0.1.1