Comparing version 0.3.0 to 0.3.1
@@ -18,3 +18,8 @@ /** | ||
self.imports = []; | ||
/** | ||
* 额外进行查找的路径,如:paths: 'path/to/app/utils', path/to/app/public/a.js文件内容:@import "mod.css" | ||
* 1、现在当前路径下寻找: path/to/app/public/mod.css | ||
* 2、若找不到,则再查找: path/to/app/utils/mod.css | ||
*/ | ||
self.paths = cfg.paths || []; | ||
utils.debug = cfg.debug; | ||
@@ -81,3 +86,16 @@ cfg.target = cfg.src || cfg.target; | ||
}else{ | ||
utils.log('cannot find file ' + filePath, 'warning'); | ||
// 若在当前文件夹找不到,就去paths中寻找,直到找到为止 | ||
self.paths.forEach(function( pathBase ){ | ||
if( !content ){ | ||
var outFilePath = path.resolve( pathBase, file); | ||
if( fs.existsSync(outFilePath) ){ | ||
var buf = fs.readFileSync( outFilePath ); | ||
content = iconv.decode(buf, config.inputEncoding ? config.inputEncoding : utils.detectCharset(buf)); | ||
} | ||
} | ||
}); | ||
if(!content){ | ||
utils.log('cannot find file ' + filePath, 'warning'); | ||
} | ||
} | ||
@@ -311,3 +329,3 @@ }else{ | ||
var funcs = []; | ||
_.forEach(files, function(file, index){ | ||
@@ -314,0 +332,0 @@ funcs.push(function(cb){ |
{ | ||
"name":"css-combo", | ||
"version":"0.3.0", | ||
"version":"0.3.1", | ||
"description":"css module combo tool", | ||
@@ -36,3 +36,3 @@ "author":"daxingplay <daxingplay@gmail.com>", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha -t 20000" | ||
}, | ||
@@ -39,0 +39,0 @@ "licenses":[ |
@@ -50,2 +50,3 @@ # css-combo | ||
* debug: {Boolean} 是否打印日志 | ||
* paths: {Array} `@import`额外查找的路径。 | ||
@@ -52,0 +53,0 @@ ### 在grunt中使用 ### |
@@ -12,2 +12,3 @@ var CssCombo = require('../lib/index'), | ||
debug: false, | ||
paths: [ path.resolve(__dirname, 'css/external' ) ], | ||
inputEncoding: 'gbk', | ||
@@ -28,3 +29,3 @@ outputEncoding: 'gbk', | ||
} | ||
if (report.imports.length !== 7) { | ||
if (report.imports.length !== 8) { | ||
throw new Error('report.imports Error'); | ||
@@ -31,0 +32,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
650700
30
2705
68