New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-peaches

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-peaches - npm Package Compare versions

Comparing version

to
0.2.3

24

Gruntfile.js

@@ -35,15 +35,15 @@ /*

options: {
"servers":{
"beautify": false , // 是否需要格式化输出,默认为 false
"model":"local", // 指定上传图片到哪台服务器,默认支持 'alipay', 'tfsdaily', 默认为 alipay
"format":"png8", // 输出图片的格式,支持 png8 和 png24, 默认为 png8
"sort":"h", // 输出图片的排列规则, h 为竖排, v 为横排 默认为 h
"alipay":{
"name": "alipay",
"root": "./images",
"tmp": "./tmp",
"bizName": "linzhi.gao",
"token": "linzhi.gao"
}
"servers":{
"beautify": false , // 是否需要格式化输出,默认为 false
"model":"local", // 指定上传图片到哪台服务器,默认支持 'alipay', 'tfsdaily', 默认为 alipay
"format":"png8", // 输出图片的格式,支持 png8 和 png24, 默认为 png8
"sort":"h", // 输出图片的排列规则, h 为竖排, v 为横排 默认为 h
"alipay":{
"name": "alipay",
"root": "./images",
"tmp": "./tmp",
"bizName": "linzhi.gao",
"token": "linzhi.gao"
}
}
},

@@ -50,0 +50,0 @@ files: [{

{
"name": "grunt-peaches",
"description": "The Grunt task for peaches.",
"version": "0.2.2",
"version": "0.2.3",
"author": {

@@ -6,0 +6,0 @@ "name": "afc163",

@@ -68,4 +68,9 @@ # grunt-peaches

### 0.2.3
- Fix https://github.com/afc163/grunt-peaches/pull/4
- Remove tmp sprite image.
### 0.2.0
Support customize options.
- Support customize options.

@@ -15,3 +15,3 @@ /*

// creation: http://gruntjs.com/creating-tasks
var path = require('path');

@@ -24,69 +24,68 @@

// Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
model: "alipay",
servers: {
"alipay": {
"name":"alipay",
"root":"./tmp",
"username":"liuqin.sheng",
"tmp":"./tmp",
"baseURI":"https://i.alipayobjects.com",
"uploadUrl":"https://ecmng.alipay.com/home/uploadFile.json"
},
"tfsdaily": {
"name": "tfsdaily",
"root": "./images",
"tmp": "./tmp"
}
}
});
var options = this.options({
model: "alipay",
servers: {
"alipay": {
"name": "alipay",
"root": "./tmp",
"username": "liuqin.sheng",
"tmp": "./tmp",
"baseURI": "https://i.alipayobjects.com",
"uploadUrl": "https://ecmng.alipay.com/home/uploadFile.json"
},
"tfsdaily": {
"name": "tfsdaily",
"root": "./images",
"tmp": "./tmp"
}
}
});
if(!options.server){
options.server = options.servers[options.model];
if(!options.server) {
options.server = options.servers[options.model];
}
var destfile, src, srcContent;
grunt.util.async.map(this.files, function(fileObj, callback) {
if( fileObj.src.length > 1 ){
grunt.log.warn('This plugin don\'t support multi src file mapping to one dest file');
callback();
return;
}
var fname, destfile, src;
this.files.forEach(function(fileObj) {
fileObj.src.forEach(function(fpath) {
var src = fileObj.src[0];
var destfile = fileObj.dest;
if (fpath.indexOf('-debug.css') > 0) {
return;
}
// get the right filename and filepath
if (fileObj.cwd) {
// not expanded
fname = fpath;
fpath = path.join(fileObj.cwd, fpath);
} else {
fname = path.relative(fileObj.orig.cwd || '', fpath);
}
if (grunt.file.isDir(fpath)) {
grunt.file.mkdir(fpath);
if (src.indexOf('-debug.css') > 0) {
callback();
return;
}
srcContent = grunt.file.read(src);
require('peaches')(srcContent, options, function(err, styleText) {
if (err) {
grunt.log.writeln('Peaches error: ' + err + '.');
callback(err);
return;
}
src = grunt.file.read(fpath);
destfile = path.join(fileObj.dest, fname);
// Write the destination file.
grunt.file.write(destfile, styleText);
require('peaches')(src, options, function(err, styleText) {
if (err) {
grunt.log.writeln('Peaches error: ' + err + '.');
return;
}
// Print a success message.
grunt.log.writeln('File "' + destfile + '" created.');
// Write the destination file.
grunt.file.write(destfile, styleText);
// Remove temp png files
grunt.file.glob.sync('sprite-*.png').forEach(function(f) {
grunt.file.delete(f);
});
// Print a success message.
grunt.log.writeln('File "' + destfile + '" created.');
// Remove temp png files
grunt.file.glob.sync('sprite-*.png').forEach(function(f) {
grunt.file.delete(f);
});
callback();
done();
});
});
}, function(err,results) {
err ? done(false) : done();
});

@@ -93,0 +92,0 @@

@@ -34,3 +34,3 @@ 'use strict';

var actual = grunt.file.read('test/tmp/example.css');
var expected = grunt.file.read('test/expected/sprites.css');
var expected = grunt.file.read('test/expected/sprites.css').trim();
test.equal(actual, expected, 'should describe what the default behavior is.');

@@ -37,0 +37,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet