Comparing version 0.1.6 to 0.1.7
@@ -23,5 +23,5 @@ var fs = require('fs'), | ||
if(typeof cfg.exclude == 'undefined'){ | ||
cfg.exclude = [/.combo.css/, /-min.css/, /.combine.css/]; | ||
} | ||
// if(typeof cfg.exclude == 'undefined'){ | ||
// cfg.exclude = [/.combo.css/, /-min.css/, /.combine.css/]; | ||
// } | ||
@@ -69,4 +69,4 @@ cfg.compress = cfg.compress == 0 ? 0 : 1; | ||
utils.log('Try to get remote file: ' + file, 'debug'); | ||
utils.getRemoteFile(file, function(data){ | ||
content = iconv.decode(data, utils.detectCharset(data)); | ||
utils.getRemoteFile(file, function(data, charset){ | ||
content = iconv.decode(data, charset); | ||
callback && callback(content); | ||
@@ -103,3 +103,8 @@ }); | ||
var comboFile = path.join(config.output, path.basename(config.target).replace(/(.source)?.css/, cssFileExt)); | ||
var comboFile = config.output; | ||
// if output is not a file name, then generate a file name with .combo.css or .css. | ||
if(path.extname(config.output) !== '.css'){ | ||
comboFile = path.join(config.output, path.basename(config.target).replace(/(.source)?.css/, cssFileExt)); | ||
} | ||
utils.log('start generate combo file: ' + comboFile, 'debug'); | ||
@@ -172,8 +177,4 @@ | ||
callback && callback(); | ||
self.clean(); | ||
}); | ||
}); | ||
}, | ||
clean: function(){ | ||
delete this; | ||
} | ||
@@ -180,0 +181,0 @@ }; |
@@ -1,3 +0,2 @@ | ||
var jschardet = require('jschardet'), | ||
fs = require('fs'), | ||
var fs = require('fs'), | ||
url = require('url'), | ||
@@ -28,8 +27,9 @@ path = require('path'), | ||
charset = result[1]; | ||
}else{ | ||
var detect = jschardet.detect(input); | ||
if(detect && detect.confidence > 0.9){ | ||
charset = detect.encoding; | ||
} | ||
} | ||
// else{ | ||
// var detect = jschardet.detect(input); | ||
// if(detect && detect.confidence > 0.9){ | ||
// charset = detect.encoding; | ||
// } | ||
// } | ||
return charset; | ||
@@ -56,2 +56,10 @@ }, | ||
// debug && console.log('status: ' + res.statusCode); | ||
var charset = 'utf-8'; | ||
if(typeof res.headers['content-type'] !== 'undefined'){ | ||
var regResult = res.headers['content-type'].match(/;charset=(\S+)/); | ||
if(regResult !== null && regResult[1]){ | ||
charset = regResult[1]; | ||
self.log('The charset of url ' + filePath + ' is: ' + charset, 'debug'); | ||
} | ||
} | ||
res.on('data', function(chunk){ | ||
@@ -77,3 +85,3 @@ // content += chunk; | ||
} | ||
callback && callback(content); | ||
callback && callback(content, charset); | ||
}); | ||
@@ -80,0 +88,0 @@ }); |
{ | ||
"name":"css-combo", | ||
"version":"0.1.6", | ||
"version":"0.1.7", | ||
"description":"css combo tool", | ||
@@ -25,4 +25,3 @@ "author":"Dorange <daxingplay@gmail.com>", | ||
"iconv-lite":">=0.1.0", | ||
"native2ascii":">=0.0.5", | ||
"jschardet":">=1.0.2" | ||
"native2ascii":">=0.0.5" | ||
}, | ||
@@ -29,0 +28,0 @@ "licenses":[ |
@@ -19,4 +19,4 @@ # css-combo | ||
* outputEncoding��{String} ����ļ����룬��ѡ��Ĭ��UTF-8�����ѡ����ѹ�������ᴦ����ascii | ||
* output��{String} ���Ŀ¼������ʹ�����·�� | ||
* exclude��{Array} �������������飬��ѡ��Ĭ�ϲ�����[/.combine.css/, /-min.css/, /.combo.css/] | ||
* output��{String} ���Ŀ¼�������������·�������ļ������Ƽ���������ʹ�����·�� | ||
* exclude��{Array} �������������飬��ѡ��Ĭ�Ͽ� | ||
* compress: {Boolean} �Ƿ�ѹ����Ĭ��Ϊtrue����������ͬYUICompressor | ||
@@ -23,0 +23,0 @@ * debug: {Boolean} �Ƿ��ӡ��־ |
@@ -5,7 +5,7 @@ var CssCombo = require('../lib/index'); | ||
target:'css/test.source.css', | ||
debug: false, | ||
debug: true, | ||
inputEncoding: 'gbk', | ||
outputEncoding: 'gbk', | ||
output:'css/', | ||
output:'css/test.combo.css', | ||
compress: 0 | ||
}); |
32904
2
704
- Removedjschardet@>=1.0.2
- Removedjschardet@3.1.4(transitive)