gulp.spritesmith
Advanced tools
Comparing version 6.6.0 to 6.7.0
# gulp.spritesmith changelog | ||
6.7.0 - Switched from `twolfson-style` to ESLint | ||
6.6.0 - Removed support for Node.js < 4 | ||
@@ -3,0 +5,0 @@ |
@@ -128,5 +128,5 @@ // Load our dependencies | ||
var retinaSrcPatterns = Array.isArray(retinaSrcFilter) ? retinaSrcFilter : [retinaSrcFilter]; | ||
images = images.filter(function filterSrcFile (file) { | ||
images = images.filter(function filterSrcFile(file) { | ||
// If we have a retina file, filter it out | ||
var matched = retinaSrcPatterns.some(function matchMinimatches (retinaSrcPattern) { | ||
var matched = retinaSrcPatterns.some(function matchMinimatches(retinaSrcPattern) { | ||
var minimatch = new Minimatch(unrelative(file.cwd, retinaSrcPattern)); | ||
@@ -171,4 +171,4 @@ return minimatch.match(file.path); | ||
var spritesmith = new Spritesmith(spritesmithParams); | ||
var retinaSpritesmithParams; | ||
var retinaSpritesmith; | ||
var retinaSpritesmithParams; // eslint-disable-line | ||
var retinaSpritesmith; // eslint-disable-line | ||
if (retinaImages) { | ||
@@ -184,14 +184,14 @@ retinaSpritesmithParams = _.defaults({ | ||
// Load in our normal images | ||
function generateNormalImages (callback) { | ||
function generateNormalImages(callback) { | ||
spritesmith.createImages(images, callback); | ||
}, | ||
// If we have retina images, load them in as well | ||
function generateRetinaSpritesheet (callback) { | ||
function generateRetinaSpritesheet(callback) { | ||
if (retinaImages) { | ||
retinaSpritesmith.createImages(retinaImages, callback); | ||
return retinaSpritesmith.createImages(retinaImages, callback); | ||
} else { | ||
process.nextTick(callback); | ||
return process.nextTick(callback); | ||
} | ||
} | ||
], function handleImages (err, resultArr) { | ||
], function handleImages(err, resultArr) { | ||
// If an error occurred, emit it | ||
@@ -210,3 +210,3 @@ if (err) { | ||
var errorEncountered = false; | ||
normalSprites.forEach(function validateImageSizes (normalSprite, i) { | ||
normalSprites.forEach(function validateImageSizes(normalSprite, i) { | ||
var retinaSprite = retinaSprites[i]; | ||
@@ -249,3 +249,3 @@ if (retinaSprite.width !== normalSprite.width * 2 || retinaSprite.height !== normalSprite.height * 2) { | ||
}; | ||
var cssVarMap = params.cssVarMap || function noop () {}; | ||
var cssVarMap = params.cssVarMap || function noop() {}; | ||
var cleanCoords = []; | ||
@@ -275,5 +275,5 @@ | ||
// If we have retina sprites | ||
var retinaCleanCoords; | ||
var retinaGroups; | ||
var retinaSpritesheetInfo; | ||
var retinaCleanCoords; // eslint-disable-line | ||
var retinaGroups; // eslint-disable-line | ||
var retinaSpritesheetInfo; // eslint-disable-line | ||
if (retinaResult) { | ||
@@ -293,3 +293,3 @@ // Generate a listing of CSS variables | ||
// Clean up the file name of the file | ||
Object.getOwnPropertyNames(retinaCoordinates).sort().forEach(function prepareRetinaTemplateData (file) { | ||
Object.getOwnPropertyNames(retinaCoordinates).sort().forEach(function prepareRetinaTemplateData(file) { | ||
var name = getCoordinateName(file); | ||
@@ -318,3 +318,3 @@ var coords = retinaCoordinates[file]; | ||
// Generate groups for our coordinates | ||
retinaGroups = cleanCoords.map(function getRetinaGroups (normalSprite, i) { | ||
retinaGroups = cleanCoords.map(function getRetinaGroups(normalSprite, i) { | ||
// Generate our group | ||
@@ -332,3 +332,3 @@ // DEV: Name is inherited from `cssVarMap` on normal sprite | ||
if (handlebarsHelpers) { | ||
Object.keys(handlebarsHelpers).forEach(function registerHelper (helperKey) { | ||
Object.keys(handlebarsHelpers).forEach(function registerHelper(helperKey) { | ||
templater.registerHandlebarsHelper(helperKey, handlebarsHelpers[helperKey]); | ||
@@ -386,3 +386,3 @@ }); | ||
// e.g. spritesmith.split() = {css, img} | ||
result.image.on('error', function forwardImgError (err) { | ||
result.image.on('error', function forwardImgError(err) { | ||
that.emit('error', err); | ||
@@ -401,3 +401,3 @@ }); | ||
}); | ||
retinaResult.image.on('error', function forwardImgError (err) { | ||
retinaResult.image.on('error', function forwardImgError(err) { | ||
that.emit('error', err); | ||
@@ -404,0 +404,0 @@ }); |
{ | ||
"name": "gulp.spritesmith", | ||
"description": "Convert a set of images into a spritesheet and CSS variables via gulp", | ||
"version": "6.6.0", | ||
"version": "6.7.0", | ||
"homepage": "https://github.com/twolfson/gulp.spritesmith", | ||
@@ -24,5 +24,4 @@ "author": { | ||
"scripts": { | ||
"precheck": "twolfson-style precheck docs/ lib/ test/", | ||
"lint": "twolfson-style lint docs/ lib/ test/", | ||
"pretest": "twolfson-style install", | ||
"precheck": "eslint docs/ lib/ test/", | ||
"lint": "eslint docs/ lib/ test/ --max-warnings 0", | ||
"test": "npm run precheck && npm run test-mocha && npm run lint", | ||
@@ -42,2 +41,4 @@ "test-mocha": "cd test && mocha . --timeout 60000" | ||
"devDependencies": { | ||
"eslint": "~4.10.0", | ||
"eslint-config-twolfson": "~1.0.0", | ||
"foundry": "~4.3.2", | ||
@@ -50,4 +51,2 @@ "foundry-release-git": "~2.0.2", | ||
"js-yaml": "~3.8.2", | ||
"jscs": "~3.0.7", | ||
"jshint": "~2.9.4", | ||
"merge-stream": "~1.0.1", | ||
@@ -58,3 +57,2 @@ "mocha": "~3.2.0", | ||
"rimraf": "~2.6.1", | ||
"twolfson-style": "~1.6.0", | ||
"vinyl-buffer": "~1.0.0" | ||
@@ -61,0 +59,0 @@ }, |
@@ -22,24 +22,27 @@ // Load in dependencies | ||
gulp.task('sprite-default', function () { | ||
return gulp.src(images).pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.css' | ||
})) | ||
.pipe(gulp.dest('actual-files/default/')); | ||
return gulp.src(images) | ||
.pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.css' | ||
})) | ||
.pipe(gulp.dest('actual-files/default/')); | ||
}); | ||
gulp.task('sprite-retina', function () { | ||
return gulp.src(retinaImages).pipe(spritesmith({ | ||
retinaSrcFilter: 'test-files/*@2x.png', | ||
imgName: 'sprite.png', | ||
retinaImgName: 'sprite@2x.png', | ||
cssName: 'sprite.css' | ||
})) | ||
.pipe(gulp.dest('actual-files/retina/')); | ||
return gulp.src(retinaImages) | ||
.pipe(spritesmith({ | ||
retinaSrcFilter: 'test-files/*@2x.png', | ||
imgName: 'sprite.png', | ||
retinaImgName: 'sprite@2x.png', | ||
cssName: 'sprite.css' | ||
})) | ||
.pipe(gulp.dest('actual-files/retina/')); | ||
}); | ||
gulp.task('sprite-two-streams', function () { | ||
var data = gulp.src(images).pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.css' | ||
})); | ||
var data = gulp.src(images) | ||
.pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.css' | ||
})); | ||
var imgStream = data.img.pipe(gulp.dest('actual-files/two-streams/')); | ||
@@ -63,97 +66,104 @@ var cssStream = data.css.pipe(gulp.dest('actual-files/two-streams/')); | ||
gulp.task('sprite-retina-same-name', function () { | ||
return gulp.src(retinaImages).pipe(spritesmith({ | ||
retinaSrcFilter: 'test-files/*@2x.png', | ||
imgName: 'sprite.png', | ||
retinaImgName: 'sprite@2x.png', | ||
cssVarMap: function (sprite) { | ||
// Coerce all 1x and 2x sprites to same name | ||
// DEV: This emulates `1x/icon.png` and `2x/icon.png` folders | ||
sprite.name = sprite.name.replace('@2x', ''); | ||
}, | ||
cssName: 'sprite.css' | ||
})) | ||
.pipe(gulp.dest('actual-files/retina-same-name/')); | ||
return gulp.src(retinaImages) | ||
.pipe(spritesmith({ | ||
retinaSrcFilter: 'test-files/*@2x.png', | ||
imgName: 'sprite.png', | ||
retinaImgName: 'sprite@2x.png', | ||
cssVarMap: function (sprite) { | ||
// Coerce all 1x and 2x sprites to same name | ||
// DEV: This emulates `1x/icon.png` and `2x/icon.png` folders | ||
sprite.name = sprite.name.replace('@2x', ''); | ||
}, | ||
cssName: 'sprite.css' | ||
})) | ||
.pipe(gulp.dest('actual-files/retina-same-name/')); | ||
}); | ||
gulp.task('sprite-formats', function () { | ||
return gulp.src(images, {read: false}).pipe(spritesmith({ | ||
imgName: 'sprite.jpg', | ||
cssName: 'sprite.css', | ||
imgOpts: { | ||
format: 'png' | ||
}, | ||
cssFormat: 'stylus', | ||
engine: 'phantomjssmith', | ||
// Use `top-down` for easier testing | ||
algorithm: 'top-down' | ||
})) | ||
.pipe(gulp.dest('actual-files/formats/')); | ||
return gulp.src(images, {read: false}) | ||
.pipe(spritesmith({ | ||
imgName: 'sprite.jpg', | ||
cssName: 'sprite.css', | ||
imgOpts: { | ||
format: 'png' | ||
}, | ||
cssFormat: 'stylus', | ||
engine: 'phantomjssmith', | ||
// Use `top-down` for easier testing | ||
algorithm: 'top-down' | ||
})) | ||
.pipe(gulp.dest('actual-files/formats/')); | ||
}); | ||
gulp.task('sprite-options', function () { | ||
return gulp.src(images).pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.css', | ||
imgPath: '../../everywhere.png', | ||
algorithm: 'alt-diagonal' | ||
})) | ||
.pipe(gulp.dest('actual-files/options/')); | ||
return gulp.src(images) | ||
.pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.css', | ||
imgPath: '../../everywhere.png', | ||
algorithm: 'alt-diagonal' | ||
})) | ||
.pipe(gulp.dest('actual-files/options/')); | ||
}); | ||
gulp.task('sprite-template', function () { | ||
return gulp.src(images).pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.scss', | ||
cssTemplate: 'test-files/scss.template.handlebars', | ||
// Use `top-down` for easier testing | ||
algorithm: 'top-down' | ||
})) | ||
.pipe(gulp.dest('actual-files/template/')); | ||
return gulp.src(images) | ||
.pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.scss', | ||
cssTemplate: 'test-files/scss.template.handlebars', | ||
// Use `top-down` for easier testing | ||
algorithm: 'top-down' | ||
})) | ||
.pipe(gulp.dest('actual-files/template/')); | ||
}); | ||
gulp.task('sprite-spritesheet-name', function () { | ||
return gulp.src(images).pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.scss', | ||
cssSpritesheetName: 'icons', | ||
// Use `top-down` for easier testing | ||
algorithm: 'top-down' | ||
})) | ||
.pipe(gulp.dest('actual-files/spritesheet-name/')); | ||
return gulp.src(images) | ||
.pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.scss', | ||
cssSpritesheetName: 'icons', | ||
// Use `top-down` for easier testing | ||
algorithm: 'top-down' | ||
})) | ||
.pipe(gulp.dest('actual-files/spritesheet-name/')); | ||
}); | ||
gulp.task('sprite-retina-mapped', function () { | ||
return gulp.src(retinaImages).pipe(spritesmith({ | ||
retinaSrcFilter: 'test-files/*@2x.png', | ||
imgName: 'sprite.png', | ||
retinaImgName: 'sprite@2x.png', | ||
cssName: 'sprite.scss', | ||
cssSpritesheetName: 'icons', | ||
cssVarMap: function (sprite) { | ||
// Rename `sprite` to `icon` (e.g. `sprite1` -> `icon1`) | ||
sprite.name = sprite.name.replace('sprite', 'icon'); | ||
}, | ||
cssRetinaSpritesheetName: 'retina-icons', | ||
cssRetinaGroupsName: 'icon-groups', | ||
// Use `top-down` for easier testing | ||
algorithm: 'top-down' | ||
})) | ||
.pipe(gulp.dest('actual-files/retina-mapped/')); | ||
return gulp.src(retinaImages) | ||
.pipe(spritesmith({ | ||
retinaSrcFilter: 'test-files/*@2x.png', | ||
imgName: 'sprite.png', | ||
retinaImgName: 'sprite@2x.png', | ||
cssName: 'sprite.scss', | ||
cssSpritesheetName: 'icons', | ||
cssVarMap: function (sprite) { | ||
// Rename `sprite` to `icon` (e.g. `sprite1` -> `icon1`) | ||
sprite.name = sprite.name.replace('sprite', 'icon'); | ||
}, | ||
cssRetinaSpritesheetName: 'retina-icons', | ||
cssRetinaGroupsName: 'icon-groups', | ||
// Use `top-down` for easier testing | ||
algorithm: 'top-down' | ||
})) | ||
.pipe(gulp.dest('actual-files/retina-mapped/')); | ||
}); | ||
gulp.task('sprite-empty', function () { | ||
return gulp.src(images).pipe(through2.obj( | ||
// On data, do nothing and callback | ||
function onEmptyData (file, encoding, cb) { | ||
cb(); | ||
}, | ||
// On end, callback with nothing | ||
function onEmptyEnd (cb) { | ||
cb(); | ||
} | ||
)).pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.scss' | ||
})) | ||
.pipe(gulp.dest('actual-files/empty/')); | ||
return gulp.src(images) | ||
.pipe(through2.obj( | ||
// On data, do nothing and callback | ||
function onEmptyData(file, encoding, cb) { | ||
cb(); | ||
}, | ||
// On end, callback with nothing | ||
function onEmptyEnd(cb) { | ||
cb(); | ||
} | ||
)).pipe(spritesmith({ | ||
imgName: 'sprite.png', | ||
cssName: 'sprite.scss' | ||
})) | ||
.pipe(gulp.dest('actual-files/empty/')); | ||
}); |
@@ -6,3 +6,3 @@ // Load in dependencies | ||
exports.run = function (cmd) { | ||
before(function runFn (done) { | ||
before(function runFn(done) { | ||
exec(cmd, function (err, stdout, stderr) { | ||
@@ -17,3 +17,3 @@ if (!err && stderr) { | ||
exports.runSaveError = function (cmd) { | ||
before(function runFn (done) { | ||
before(function runFn(done) { | ||
var that = this; | ||
@@ -28,5 +28,5 @@ exec(cmd, function (err, stdout, stderr) { | ||
}); | ||
after(function cleanup () { | ||
after(function cleanup() { | ||
delete this.err; | ||
}); | ||
}; |
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
15
1080
287437
66