@makano/rew 1.2.69 → 1.2.70

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ const path = require("path");
9
9
  const execLib = require("../functions/exec");
10
10
  const { findAppInfo } = require("../misc/findAppInfo");
11
11
  const { USING_DEFAULT, Usage, Namespace } = require("../const/usage");
12
+ const runtime = require("./runtime");
12
13
 
13
14
  let mainFile = "";
14
15
  const isMainFile = (filepath) => filepath == mainFile;
@@ -114,9 +115,8 @@ module.exports.prepareContext = function (
114
115
  const childContext = {...context, ...name.namespace, trigger};
115
116
  childContext.currentNamespace = name.namespace;
116
117
  childContext.parentNamespace = context;
117
- with(childContext){
118
- eval(`(${trigger.toString()})()`);
119
- }
118
+ const code = `(${trigger.toString()})()`;
119
+ runtime.exec(code, childContext, code, context.module.filepath);
120
120
  } else if(name instanceof Usage) {
121
121
  const v = name.trigger(...params) || true;
122
122
  if(name.save !== false) context.__using__[name.name] = v;
@@ -7,9 +7,9 @@ const path = require('path');
7
7
 
8
8
  const preScript = readFileSync(path.join(__dirname, '../const/pre-exec.js'), { encoding: 'utf-8' });
9
9
 
10
- const exec = (module.exports.exec = function (code, context, original = '') {
10
+ const exec = (module.exports.exec = function (code, context, original = '', filepath) {
11
11
  return vm.runInNewContext(code, context.do ? null : vm.createContext(context), {
12
- filename: context.module.filepath,
12
+ filename: filepath || context.module.filepath,
13
13
  lineOffset: (original.split('\n').length + preScript.split('\n').length) - code.split('\n').length,
14
14
  displayErrors: true,
15
15
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.69",
3
+ "version": "1.2.70",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {