Comparing version 0.1.0-0 to 0.2.0-0
@@ -83,3 +83,2 @@ var inutil = require("./util.js"); | ||
var _resolvePaths = this.getPaths(cssFilePath); | ||
var _this = this; | ||
@@ -86,0 +85,0 @@ fs.stat(cssFilePath, function(err, result){ |
@@ -6,5 +6,3 @@ var fs = require("fs"); | ||
var IMPORT_REGEXP = /@import\s.+;/g; | ||
var FILE_REGEXP = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/; | ||
/** | ||
@@ -41,2 +39,29 @@ * Find exist file. | ||
function trimQuate(syntax){ | ||
if(/^'(.*)'$/.test(syntax)){ | ||
syntax = syntax.replace(/^'/,''); | ||
syntax = syntax.replace(/'$/,''); | ||
return syntax | ||
} | ||
if(/^"(.*)"$/.test(syntax)){ | ||
syntax = syntax.replace(/^"/,''); | ||
syntax = syntax.replace(/"$/,''); | ||
return syntax; | ||
} | ||
return syntax; | ||
} | ||
function findImportFile(syntax){ | ||
var URL_REGEXP = /url\((.*)\)/ | ||
if(URL_REGEXP.test(syntax)){ | ||
var matches = syntax.match(URL_REGEXP); | ||
return trimQuate(matches[1]); | ||
} | ||
var FILE_REGEXP = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/; | ||
if(FILE_REGEXP.test(syntax)){ | ||
var matches = syntax.match(FILE_REGEXP); | ||
var fileName = matches[1] || matches[2]; | ||
return fileName | ||
} | ||
} | ||
function getReplaceMap(css, resolvePaths){ | ||
@@ -55,7 +80,4 @@ var _replaceMap = {}; | ||
var importSyntax = importMatches[i]; | ||
if(FILE_REGEXP.test(importSyntax) === false){ | ||
continue; | ||
} | ||
var matches = importSyntax.match(FILE_REGEXP); | ||
var fileName = matches[1] || matches[2]; | ||
var fileName = findImportFile(importSyntax) | ||
if(/\.css$/.test(fileName) === false){ | ||
@@ -62,0 +84,0 @@ continue; |
{ | ||
"name": "cssjoin", | ||
"version": "0.1.0-0", | ||
"version": "0.2.0-0", | ||
"description": "Extend css @import loaded file", | ||
@@ -18,3 +18,4 @@ "main": "index.js", | ||
"mocha": "~1.7.3", | ||
"should": "~1.2.1" | ||
"should": "~1.2.1", | ||
"rewire": "~1.1.2" | ||
}, | ||
@@ -21,0 +22,0 @@ "scripts": { |
8314
232
3