feat: compatible windows and support disable function
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
7dad0e7abc
commit
0dfe04040e
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
var log;
|
||||
var boot;
|
||||
var engineDisable;
|
||||
// noinspection ThisExpressionReferencesGlobalObjectJS
|
||||
var global = this;
|
||||
/**
|
||||
@ -27,7 +28,7 @@ var global = this;
|
||||
// Plugin file decompression to folder when file not exist
|
||||
release(root, '(plugins)+/.*', false);
|
||||
load(root + '/core/ployfill.js')(root, logger);
|
||||
require('@ms/core');
|
||||
engineDisable = require('@ms/core').default;
|
||||
};
|
||||
|
||||
var pluginYml;
|
||||
|
@ -5,7 +5,7 @@
|
||||
// Init Global Function
|
||||
global.noop = global.engineDisable = function() { };
|
||||
global.engineLoad = load;
|
||||
global.load = function __PreventGlobalLoadFunction__() {
|
||||
global.load = load = function __PreventGlobalLoadFunction__() {
|
||||
throw new Error('Internal engine system not allow use `load` function!');
|
||||
};
|
||||
// Init console and require
|
||||
|
@ -31,7 +31,6 @@
|
||||
var File = Java.type("java.io.File");
|
||||
var FileNotFoundException = Java.type("java.io.FileNotFoundException");
|
||||
var separatorChar = File.separatorChar;
|
||||
var cacheDir = parent + separatorChar + "runtime";
|
||||
|
||||
function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
@ -43,12 +42,6 @@
|
||||
return t;
|
||||
};
|
||||
|
||||
try {
|
||||
base.delete(cacheDir);
|
||||
} catch (ex) {
|
||||
console.ex(ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为一个文件
|
||||
* @param file
|
||||
@ -81,16 +74,6 @@
|
||||
return file.absolutePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的文件名称
|
||||
* @param file
|
||||
* @returns {string}
|
||||
* @private
|
||||
*/
|
||||
function _cacheFile(file) {
|
||||
return _absolute(file).replace(parent, cacheDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析模块名称为文件
|
||||
* 按照下列顺序查找
|
||||
@ -211,19 +194,12 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
function compileJs(module, file, optional) {
|
||||
var cacheFile = _cacheFile(file);
|
||||
var origin = base.read(file);
|
||||
if (optional.hook) {
|
||||
origin = optional.hook(origin);
|
||||
}
|
||||
base.save(cacheFile, "(function $(module, exports, require, __dirname, __filename) {" + origin + "});");
|
||||
// 使用 load 可以保留行号和文件名称
|
||||
var compiledWrapper = engineLoad(cacheFile);
|
||||
try {
|
||||
base.delete(cacheFile);
|
||||
} catch (ex) {
|
||||
cacheFile.deleteOnExit();
|
||||
}
|
||||
// 2019-09-19 使用 扩展函数直接 load 无需保存文件 删除文件
|
||||
var compiledWrapper = engineLoad({ script: "(function $(module, exports, require, __dirname, __filename) {" + origin + "});", name: file });
|
||||
compiledWrapper.apply(module.exports, [
|
||||
module, module.exports, module.require, file.parentFile, file
|
||||
]);
|
||||
|
@ -1,7 +1,5 @@
|
||||
package pw.yumc.MiaoScript;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA
|
||||
*
|
||||
@ -9,7 +7,6 @@ import org.junit.Test;
|
||||
* Created on 2017/9/14 10:08.
|
||||
*/
|
||||
public class MiaoScriptTest {
|
||||
@Test
|
||||
public void testBoot() {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user