Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

broccoli-sprite

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-sprite - npm Package Compare versions

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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc