@makano/rew 1.2.93 → 1.2.94
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
|
|
1
|
+
const { compile } = require("../modules/compiler")
|
2
|
+
|
3
|
+
const _compilePart = (code, filepath) => compile(
|
4
|
+
{
|
5
|
+
path: filepath,
|
6
|
+
content: code
|
7
|
+
},
|
8
|
+
{}
|
9
|
+
);
|
10
|
+
|
11
|
+
module.exports = (filepath) => ({
|
12
|
+
_compilePart: (code) => {
|
13
|
+
return _compilePart(code, filepath);
|
14
|
+
},
|
15
|
+
_call: (fn, ...args) => args.length ? fn.call(...args) : fn()
|
16
|
+
})
|
@@ -330,6 +330,19 @@ function compileRewStuff(content, options) {
|
|
330
330
|
}
|
331
331
|
}
|
332
332
|
|
333
|
+
if (token.type === "COMMENT" && token.value.startsWith('#alias')) {
|
334
|
+
let value = '#declare';
|
335
|
+
if(token.value.match(/^#alias\*/)) value += '*';
|
336
|
+
let subs;
|
337
|
+
subs = token.value.replace(/^#alias/, '');
|
338
|
+
if(token.value.endsWith('*')) subs.split('*')[1];
|
339
|
+
|
340
|
+
value += ' key';
|
341
|
+
value += ' ' + subs.replace(/([\S]+)\s*=\s*([\S]+)/, '"$1" = $2').trim();
|
342
|
+
value += ';';
|
343
|
+
declareAlias(aliases, {...token, value});
|
344
|
+
}
|
345
|
+
|
333
346
|
if (token.type === "COMMENT" && token.value.startsWith('#declare')) {
|
334
347
|
if (token.value.includes(';')) {
|
335
348
|
declareAlias(aliases, token);
|
@@ -12,6 +12,7 @@ const { USING_DEFAULT, Usage, Namespace } = require("../const/usage");
|
|
12
12
|
const runtime = require("./runtime");
|
13
13
|
const { permission } = require("process");
|
14
14
|
const { straceLog } = require("../misc/strace");
|
15
|
+
const reval = require("../functions/reval");
|
15
16
|
|
16
17
|
let mainFile = "";
|
17
18
|
const isMainFile = (filepath) => filepath == mainFile;
|
@@ -37,6 +38,7 @@ module.exports.prepareContext = function (
|
|
37
38
|
},
|
38
39
|
app: findAppInfo(filepath),
|
39
40
|
...fsLib(filepath),
|
41
|
+
...reval(filepath),
|
40
42
|
__using__: {}
|
41
43
|
};
|
42
44
|
if (options.useContext) {
|
@@ -46,11 +46,21 @@ module.exports.runPath = function runPath(filepath, options = {}, custom_context
|
|
46
46
|
}
|
47
47
|
|
48
48
|
compiled_code = preScript+'\n'+compiled_code;
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
|
50
|
+
let execd = exec(compiled_code, context, file.content);
|
51
|
+
|
52
|
+
if(context.module.main && (context.module.exports?.main || (typeof context.module.exports == "function" && context.module.exports.name == 'main'))){
|
53
|
+
const mainFn = context.module.exports.main ?? context.module.exports;
|
54
|
+
return {
|
55
|
+
context,
|
56
|
+
returns: mainFn(context.process.argv)
|
57
|
+
}
|
58
|
+
} else {
|
59
|
+
return {
|
60
|
+
context,
|
61
|
+
returns: execd,
|
62
|
+
};
|
63
|
+
}
|
54
64
|
}
|
55
65
|
|
56
66
|
if(options.async){
|