Socket
Socket
Sign inDemoInstall

css-sprite

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-sprite - npm Package Compare versions

Comparing version 0.9.7 to 0.9.8

5

bin/cli.js

@@ -72,2 +72,7 @@ #!/usr/bin/env node

})
.option('cachebuster', {
choices: ['random'],
default: false,
help: 'appends a "cache buster" to the background image in the form "?<...>" (random)'
})
.option('margin', {

@@ -74,0 +79,0 @@ default: 4,

10

lib/css-sprite.js
'use strict';
var async = require('async');
var crypto = require('crypto');
var through2 = require('through2');

@@ -110,2 +111,7 @@ var lodash = require('lodash');

var cachebuster = '';
if (opt.cachebuster === 'random') {
cachebuster = '?' + crypto.randomBytes(20).toString('hex');
}
if (retinaSprite) {

@@ -115,3 +121,3 @@ sprites.unshift({

type: 'retina',
image: (!opt.base64) ? url.resolve(opt.cssPath.replace(/\\/g, '/'), retinaSprite.relative) : 'data:' + imageinfo(retinaSprite.buffer).mimeType + ';base64,' + retinaSprite.buffer.toString('base64'),
image: (!opt.base64) ? url.resolve(opt.cssPath.replace(/\\/g, '/'), retinaSprite.relative) + cachebuster : 'data:' + imageinfo(retinaSprite.buffer).mimeType + ';base64,' + retinaSprite.buffer.toString('base64'),
total_width: sprite.canvas.width(),

@@ -132,3 +138,3 @@ total_height: sprite.canvas.height()

type: 'sprite',
image: (!opt.base64) ? url.resolve(opt.cssPath.replace(/\\/g, '/'), sprite.relative) : 'data:' + imageinfo(sprite.buffer).mimeType + ';base64,' + sprite.buffer.toString('base64'),
image: (!opt.base64) ? url.resolve(opt.cssPath.replace(/\\/g, '/'), sprite.relative) + cachebuster : 'data:' + imageinfo(sprite.buffer).mimeType + ';base64,' + sprite.buffer.toString('base64'),
total_width: sprite.canvas.width,

@@ -135,0 +141,0 @@ total_height: sprite.canvas.height

2

package.json
{
"name": "css-sprite",
"version": "0.9.7",
"version": "0.9.8",
"description": "css sprite generator",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -240,2 +240,26 @@ 'use strict';

});
it('should include a random cache buster hash on the background-image, if desired', function (done) {
var css;
vfs.src('./test/fixtures/**')
.pipe(sprite({
out: './dist/img',
name: 'sprites',
style: './dist/css/sprites.css',
cachebuster: 'random'
}))
.pipe(through2.obj(function (file, enc, cb) {
if (file.relative.indexOf('css') > -1) {
css = file;
}
cb();
}))
.on('data', noop)
.on('end', function () {
css.should.be.ok;
css.path.should.equal('./dist/css/sprites.css');
css.relative.should.equal('sprites.css');
css.contents.toString('utf-8').should.match(/background-image: url\('..\/sprites.png\?[0-9a-f]{40}'\)/);
done();
});
});
it('should return a object stream with a sprite and a scss file', function (done) {

@@ -242,0 +266,0 @@ var png, css;

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