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

css-combo

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-combo - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

50

lib/combo.js

@@ -16,3 +16,3 @@ /**

function CssCombo(cfg, callback){
function CssCombo(cfg){
var self = this;

@@ -53,3 +53,3 @@

self.config = cfg;
self.build(callback);
//self.build(callback);
}

@@ -249,3 +249,3 @@ }

},
build: function(callback){
analyze: function(callback){
var self = this,

@@ -303,3 +303,3 @@ config = self.config,

}
self.generateOutput(data);
//self.generateOutput(data);

@@ -312,37 +312,9 @@ report.imports = self.imports;

});
// fs.readFile(file, '', function(err, data){
// if(err){
// utils.log(err, 'error');
// throw self.error(err);
// }
// utils.log('Cur file is ' + self.config.target, 'debug');
// utils.log('file read: ' + file, 'debug');
//
// config.inputEncoding = config.inputEncoding ? config.inputEncoding : utils.detectCharset(data);
// var fileContent = iconv.decode(data, config.inputEncoding);
// utils.log('file charset is: ' + config.inputEncoding, 'debug');
//
// // preserve data url and comment.
// var preservedTokens = [];
// fileContent = compressor._extractDataUrls(fileContent, preservedTokens);
// fileContent = compressor._extractComments(fileContent, preservedTokens);
//
// // start analyze file content
// self.analyzeImports(fileContent, function(data){
// utils.log('analyze done.', 'debug');
// // after combo, @charset position may be changed. since the output file encoding is specified, we should remove @charset.
// data = data.replace(/@charset\s+['|"](\S*)["|'];/g, '');
// // restore all comments back.
// data = compressor._restoreComments(data, preservedTokens);
// self.generateOutput(data);
//
// report.imports = self.imports;
// report.target = self.config.target;
// report.output = self.config.output;
// report.content = data;
// callback && callback(null, report);
// });
//// self.analyzeImports();
// });
},
build: function(callback){
var self = this;
self.analyze(function(err, report){
self.generateOutput(report.content);
callback && callback(null, report);
});
}

@@ -349,0 +321,0 @@ };

@@ -13,18 +13,54 @@ /**

function _iterator(src, dest, options){
var files = [],
dests = [];
options = _.isPlainObject(options) ? _.clone(options) : {};
if(src && _.isPlainObject(src)){
options = src;
files.push(options.src || options.target);
dests.push(options.dest || options.output);
}else if(_.isString(src)){
files.push(src);
dests.push(dest);
}else{
files = src;
dests = dest;
}
//return [files, dests, options];
return function(iterator, callback){
var funcs = [];
_.forEach(files, function(file, index){
funcs.push(function(cb){
iterator({
src: file,
dest: _.isArray(dests) && dests[index] ? dests[index] : dests,
options: options
}, cb);
});
});
async.parallel(funcs, function(err, results){
callback && callback(err, results);
});
};
}
module.exports = {
build: function(src, dest, options, callback){
var files = [],
dests = [];
options = _.isPlainObject(options) ? _.clone(options) : {};
if(src && _.isPlainObject(src)){
options = src;
files.push(options.src || options.target);
dests.push(options.dest || options.output);
}else if(_.isString(src)){
files.push(src);
dests.push(dest);
}else{
files = src;
dests = dest;
for(var i = 1; i < arguments.length; i++){
if(_.isFunction(arguments[i])){
callback = arguments[i];
break;
}
}
var walker = _iterator(src, dest, options);
walker(function(item, cb){
var c = _.merge(item.options, {
src: item.src,
dest: item.dest
});
new CssCombo(c).build(cb);
}, callback);
},
analyze: function(src, dest, options, callback){
for(var i = 1; i < arguments.length; i++){

@@ -36,23 +72,12 @@ if(_.isFunction(arguments[i])){

}
var funcs = [];
_.forEach(files, function(file, index){
funcs.push(function(cb){
try{
var c = _.merge(options, {
src: file,
dest: _.isArray(dests) && dests[index] ? dests[index] : dests
});
new CssCombo(c, cb);
}catch (e){
utils.log(e, 'debug');
cb(e);
}
var walker = _iterator(src, dest, options);
walker(function(item, cb){
var c = _.merge(item.options, {
src: item.src,
dest: item.dest
});
});
async.parallel(funcs, function(err, results){
callback && callback(err, results);
});
new CssCombo(c).analyze(cb);
}, callback);
},
version: JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json'))).version
version: require('../package.json').version
};
{
"name": "css-combo",
"version": "0.4.1",
"version": "0.5.0",
"description": "css module combo tool",

@@ -5,0 +5,0 @@ "author": "daxingplay <daxingplay@gmail.com>",

@@ -61,2 +61,21 @@ var CssCombo = require('../lib/index'),

describe('When analyze', function(){
it('should get results', function(done){
CssCombo.analyze({
target: path.resolve(__dirname, 'css/test.source.css'),
debug: false,
paths: [ path.resolve(__dirname, 'css/external' ) ],
inputEncoding: 'gbk',
outputEncoding: 'gbk',
output:path.resolve(__dirname, 'css/test.combo.css'),
compress: 0
}, function(e, report){
report[0].imports.length.should.equal(8);
done();
});
});
});
describe('When build ', function(){

@@ -63,0 +82,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