Comparing version 2.0.2 to 2.0.3
@@ -55,3 +55,2 @@ var _ = alp._; | ||
} | ||
this.useCompile = !_.filter(absUrl, config.get('exclude')); | ||
@@ -81,5 +80,11 @@ this.mtime = this.getMtime(); | ||
this._content = _.read(this.realpath, this.isTextFile).toString(); | ||
} | ||
return this._content; | ||
}, | ||
getRawContent: function () { | ||
this.rawContent = _.read(this.realpath, this.isTextFile).toString(); | ||
return this.rawContent; | ||
}, | ||
setContent: function (content) { | ||
@@ -91,2 +96,9 @@ this._content = content; | ||
}, | ||
updateMd5: function(content) { | ||
if (typeof content === 'undefined') { | ||
content = this.getContent(); | ||
} | ||
this.md5 = _.md5(content); | ||
return this.md5; | ||
}, | ||
addRequire : function(id){ | ||
@@ -93,0 +105,0 @@ if(id && (id = id.trim())){ |
@@ -535,4 +535,6 @@ var esprima = require('esprima'); | ||
this.contentProcessor(file); | ||
// 同一个html中可以写多个脚本块,所以这里不做判定 | ||
if (!file.isLikeHtml && file.subpath in storage && file.mtime === cacheFile.mtime) { | ||
if (!file.isLikeHtml && file.subpath in storage && file.mtime === cacheFile.mtime && file.updateMd5() === cacheFile.md5) { | ||
return; | ||
@@ -543,3 +545,2 @@ } | ||
this.contentProcessor(file); | ||
@@ -546,0 +547,0 @@ this.emit('beforeCompile', file); |
@@ -9,2 +9,3 @@ var fs = require('fs'); | ||
var crypto = require('crypto'); | ||
@@ -104,3 +105,3 @@ var TEXT_FILE_EXTS = [ | ||
} else { | ||
fis.log.error('invalid file type [' + type + ']'); | ||
alp.log.error('invalid file type [' + type + ']'); | ||
} | ||
@@ -480,3 +481,3 @@ if (ext && ext.length) { | ||
default: | ||
fis.log.error('invalid regexp [' + pattern + '].'); | ||
alp.log.error('invalid regexp [' + pattern + '].'); | ||
} | ||
@@ -519,3 +520,3 @@ } | ||
} else { | ||
fis.log.error('unable to find [' + rPath + ']: No such file or directory.'); | ||
alp.log.error('unable to find [' + rPath + ']: No such file or directory.'); | ||
} | ||
@@ -610,3 +611,12 @@ return list.sort(); | ||
_.md5 = function (data, len) { | ||
var md5sum = crypto.createHash('md5'), | ||
encoding = typeof data === 'string' ? 'utf8' : 'binary'; | ||
md5sum.update(data, encoding); | ||
len = len || alp.config.get('md5Length') || 7; | ||
return md5sum.digest('hex').substring(0, len); | ||
}; | ||
{ | ||
"name": "alpaca-sm", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "分析Html文件依赖的js文件和css文件", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
50408
1291