Comparing version 0.1.9 to 0.2.1
@@ -8,3 +8,3 @@ var fs = require('fs'), | ||
function CssCombo(cfg, success){ | ||
function CssCombo(cfg, callback){ | ||
var self = this; | ||
@@ -33,3 +33,3 @@ | ||
self.config = cfg; | ||
self.build(success); | ||
self.build(callback); | ||
return true; | ||
@@ -39,2 +39,11 @@ } | ||
CssCombo.prototype = { | ||
error: function(e){ | ||
var self = this; | ||
return { | ||
type: e.type || 'Syntax', | ||
message: e.message, | ||
filename: path.basename(self.config.target), | ||
filepath: self.config.target | ||
} | ||
}, | ||
isExcluded: function(filename){ | ||
@@ -59,3 +68,3 @@ var config = this.config; | ||
var filePath = path.resolve(config.base, file); | ||
if(path.existsSync(filePath)){ | ||
if(fs.existsSync(filePath)){ | ||
var buf = fs.readFileSync(filePath); | ||
@@ -133,8 +142,8 @@ content = iconv.decode(buf, config.inputEncoding ? config.inputEncoding : utils.detectCharset(buf)); | ||
self.getFileContent(filePath, function(data){ | ||
if(content){ | ||
// if(content){ | ||
content = content.replace(result[0], '\n' + data + '\n'); | ||
content = self.analyzeImports(content, callback); | ||
}else{ | ||
utils.log('no content', 'debug'); | ||
} | ||
// }else{ | ||
// utils.log('no content', 'debug'); | ||
// } | ||
}); | ||
@@ -146,2 +155,3 @@ }else{ | ||
utils.log('content empty.', 'debug'); | ||
callback && callback(content); | ||
} | ||
@@ -160,2 +170,3 @@ }, | ||
utils.log(err, 'error'); | ||
throw self.error(err); | ||
} | ||
@@ -187,5 +198,10 @@ | ||
module.exports = { | ||
build: function(cfg, success){ | ||
new CssCombo(cfg, success); | ||
build: function(cfg, callback){ | ||
try{ | ||
new CssCombo(cfg, callback); | ||
}catch (e){ | ||
utils.log(e); | ||
callback && callback(e); | ||
} | ||
} | ||
}; |
@@ -38,3 +38,3 @@ var fs = require('fs'), | ||
var self = this; | ||
if(!path.existsSync(dirpath)) { | ||
if(!fs.existsSync(dirpath)) { | ||
// try to create parent dir first. | ||
@@ -41,0 +41,0 @@ self.mkdirSync(path.dirname(dirpath), mode); |
{ | ||
"name":"css-combo", | ||
"version":"0.1.9", | ||
"description":"css combo tool", | ||
"version":"0.2.1", | ||
"description":"css module combo tool", | ||
"author":"Dorange <daxingplay@gmail.com>", | ||
@@ -17,3 +17,3 @@ "homepage":"", | ||
"engines":{ | ||
"node":">=0.6.0" | ||
"node":">=0.8.1" | ||
}, | ||
@@ -20,0 +20,0 @@ "directories":{ |
@@ -12,3 +12,3 @@ # css-combo | ||
CssCombo.build(cfg); | ||
CssCombo.build(cfg, function(err){ callback(); }); | ||
@@ -15,0 +15,0 @@ * cfg:{Object} ���� |
@@ -1,10 +0,17 @@ | ||
var CssCombo = require('../lib/index'); | ||
var CssCombo = require('../lib/index'), | ||
path = require('path'); | ||
CssCombo.build({ | ||
target:'css/test.source.css', | ||
target: path.resolve(__dirname, 'css/test.source.css'), | ||
debug: true, | ||
inputEncoding: 'gbk', | ||
outputEncoding: 'gbk', | ||
// inputEncoding: 'gbk', | ||
// outputEncoding: 'gbk', | ||
output:'css/test.combo.css', | ||
compress: 0 | ||
}, function(e){ | ||
if(e){ | ||
console.dir(e); | ||
}else{ | ||
console.log('success'); | ||
} | ||
}); |
Sorry, the diff of this file is not supported yet
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
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
63624
15
1560
1