@makano/rew 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -76,7 +76,12 @@ module.exports.prepareContext = function (
|
|
76
76
|
if(!context.module.exports) context.module.exports = {};
|
77
77
|
context.module.exports[name] = object;
|
78
78
|
context[name] = object;
|
79
|
-
}, Main: (cb) =>
|
79
|
+
}, Main: (cb) => {
|
80
|
+
if(cb?.main){
|
81
|
+
cb.main._class = cb;
|
82
|
+
}
|
83
|
+
return (['main', cb?.main ?? cb]);
|
84
|
+
}, attach: (object) => {
|
80
85
|
for(let i in object){
|
81
86
|
if(!context[i]) context[i] = object[i];
|
82
87
|
}
|
@@ -52,9 +52,16 @@ module.exports.runPath = function runPath(filepath, options = {}, custom_context
|
|
52
52
|
|
53
53
|
if(context.module.main && (context.module.exports?.main || (typeof context.module.exports == "function" && context.module.exports.name == 'main'))){
|
54
54
|
const mainFn = context.module.exports.main ?? context.module.exports;
|
55
|
+
let ctx = context;
|
56
|
+
if(mainFn._class){
|
57
|
+
ctx = mainFn._class;
|
58
|
+
for(let i in context){
|
59
|
+
ctx[i] = context[i];
|
60
|
+
}
|
61
|
+
}
|
55
62
|
return {
|
56
63
|
context,
|
57
|
-
returns: mainFn.call(
|
64
|
+
returns: mainFn.call(ctx, context.process.argv)
|
58
65
|
}
|
59
66
|
} else {
|
60
67
|
return {
|