css-sprite
Advanced tools
Comparing version 0.9.7 to 0.9.8
@@ -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, |
'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 |
{ | ||
"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; |
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
96185
1128