Comparing version 2.1.0 to 2.1.1
@@ -12,2 +12,5 @@ var ParseJS = require('./parseJS.js'); | ||
var getRequireRegExp = function () { | ||
return new RegExp('(' + alp.config.get('word') + ')|(' + 'module\\.exports' + ')', 'gm'); | ||
}; | ||
function Dispatcher() { | ||
@@ -23,3 +26,5 @@ | ||
this.parseHtml.on('parse', (function (file) { | ||
this.parse(file); | ||
}).bind(this)); | ||
@@ -50,8 +55,10 @@ | ||
}, | ||
_compile: function (src, dir) { | ||
var file = src instanceof File ? src : new File(src, dir), | ||
cacheFile; | ||
_compile: function (src, isJudgeFileExist) { | ||
var file = src instanceof File ? src : new File(src, null, isJudgeFileExist), | ||
cacheFile, content; | ||
cacheFile = storage[file.subpath]; | ||
file.setContent(this.getFileContent(file)); | ||
content = this.getFileContent(file); | ||
file.setContent(content); | ||
if (!file.isLikeHtml) { | ||
@@ -62,4 +69,7 @@ if (common.equalFile(file, cacheFile)) { | ||
} | ||
storage[file.subpath] = file; | ||
if (!content.match(getRequireRegExp())) { | ||
return false; | ||
} | ||
if (!file.useCompile) { | ||
@@ -73,2 +83,3 @@ return false; | ||
storage[file.subpath] = cacheFile; | ||
console.log(file.subpath); | ||
alp.log.error(e.message); | ||
@@ -78,3 +89,3 @@ } | ||
for (var i = 0, len = file.requires.length; i < len; i++) { | ||
this._compile(file.requires[i], dir); | ||
this._compile(file.requires[i]); | ||
} | ||
@@ -84,4 +95,4 @@ } | ||
}, | ||
parse: function (src) { | ||
var result = this._compile(src), | ||
parse: function (src, isJudgeFileExist) { | ||
var result = this._compile(src, isJudgeFileExist), | ||
file; | ||
@@ -102,3 +113,3 @@ | ||
return storage; | ||
return result; | ||
} | ||
@@ -118,4 +129,6 @@ }; | ||
return dispatcher.parse(opt.src); | ||
alp.config.merge(opt.config || {}); | ||
return dispatcher.parse(opt.src, opt.isJudgeFileExist); | ||
}; | ||
@@ -11,3 +11,3 @@ var _ = alp._; | ||
function File(url, based) { | ||
function File(url, based, isUseExists) { | ||
var root = config.get('root'), | ||
@@ -23,3 +23,6 @@ absUrl, | ||
} | ||
if (!_.exists(absUrl)) { | ||
if (_.is(isUseExists, 'undefined')) { | ||
isUseExists = true; | ||
} | ||
if (isUseExists && !_.exists(absUrl)) { | ||
alp.log.error(new Error('unable to find [' + absUrl + ']:No such file ' + (based ? ('in [' + based + ']') : ''))); | ||
@@ -55,3 +58,2 @@ } | ||
this.isWrapJSClosure = this.isJsFile; | ||
if (this.isLikeCss) { | ||
@@ -58,0 +60,0 @@ this.isCanembed = config.get('readable.css'); |
@@ -76,3 +76,3 @@ var word = alp.config.get('word'); | ||
file.addARequire(aRequires[i]); | ||
nContent += _this.buildTag(new File(aRequires[i], file.dirname), file.dirname); | ||
nContent += _this.buildTag(new File(aRequires[i]), file.dirname); | ||
} | ||
@@ -79,0 +79,0 @@ |
{ | ||
"name": "alpaca-sm", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "分析Html文件依赖的js文件和css文件", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
73438
1440