feat: compatible symbolic links require

This commit is contained in:
MiaoWoo 2019-09-01 23:58:07 +08:00
parent 2d4bc3dd24
commit 160e7f4118
3 changed files with 22 additions and 6 deletions

1
.gitignore vendored
View File

@ -52,3 +52,4 @@ vendor/
# Minecraft Data
/world
**/node_modules/

View File

@ -7,4 +7,8 @@
String.prototype.format = function() {
return str.format(this, Array.prototype.slice.call(arguments, 0))
};
var indexOf = String.prototype.indexOf;
String.prototype.contains = function(searchString/*, position*/) {
return indexOf.call(this, searchString, arguments[1]) > -1;
};
})();

View File

@ -60,6 +60,17 @@
return file.canonicalPath;
}
/**
* 获得文件绝对路径
* @param file
* @returns {*}
* @private
*/
function _absolute(file) {
// noinspection JSUnresolvedVariable
return file.absolutePath;
}
/**
* 获得缓存的文件名称
* @param file
@ -67,7 +78,7 @@
* @private
*/
function _cacheFile(file) {
return _canonical(file).replace(parent, cacheDir);
return _absolute(file).replace(parent, cacheDir);
}
/**
@ -108,12 +119,12 @@
return file;
}
// JS文件
var js = new File(normalizeName(_canonical(file), ".js"));
var js = new File(normalizeName(_absolute(file), ".js"));
if (js.isFile()) {
return js;
}
// JSON文件
var json = new File(normalizeName(_canonical(file), ".json"));
var json = new File(normalizeName(_absolute(file), ".json"));
if (json.isFile()) {
return json;
}