@makano/rew 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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) => (['main', cb?.main ?? cb]), attach: (object) => {
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(context, context.process.argv)
64
+ returns: mainFn.call(ctx, context.process.argv)
58
65
  }
59
66
  } else {
60
67
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {