From fccb5395e8a5a254ffe384cdb43f559e7815ee18 Mon Sep 17 00:00:00 2001 From: ivansglazunov Date: Sat, 31 Jan 2015 04:06:57 +0000 Subject: [PATCH] Include module wrap. --- index.js | 3 ++- package.json | 2 +- readme.md | 2 +- sources/commonjs-open.js | 3 ++- tests/test.js | 1 - 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 7b9f5e3..e70554e 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,11 @@ var _ = require('lodash'); var async = require('async'); var fs = require('fs'); +var vm = require('vm'); var _stringRequire = exports._stringRequire = function(file, path) { var m = new module.constructor(); - m._compile(file, path); + vm.runInThisContext(require('module').wrap(file))(m.exports, m.require, m, path, require('path').dirname(path)); return m.exports; }; diff --git a/package.json b/package.json index 9b35998..8e34620 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "osws-templates", - "version": "0.2.5", + "version": "0.2.6", "description": "Tools for generating, extending and rendering HTML.", "keywords": [], "author": "Open Source Web Standards (http://osws.github.io/OSWS)", diff --git a/readme.md b/readme.md index ca347e2..aef0e73 100755 --- a/readme.md +++ b/readme.md @@ -1,3 +1,3 @@ -# [OSWS](https://github.com/OSWS) [Templates](https://github.com/OSWS/OSWS-Templates) [0.2.5](https://github.com/OSWS/OSWS-Templates/wiki/0.2.5) +# [OSWS](https://github.com/OSWS) [Templates](https://github.com/OSWS/OSWS-Templates) [0.2.6](https://github.com/OSWS/OSWS-Templates/wiki/0.2.6) [documentation](https://github.com/OSWS/OSWS-Templates/wiki) \ No newline at end of file diff --git a/sources/commonjs-open.js b/sources/commonjs-open.js index 1fdc9a4..d6c8324 100644 --- a/sources/commonjs-open.js +++ b/sources/commonjs-open.js @@ -1,10 +1,11 @@ var _ = require('lodash'); var async = require('async'); var fs = require('fs'); +var vm = require('vm'); var _stringRequire = exports._stringRequire = function(file, path) { var m = new module.constructor(); - m._compile(file, path); + vm.runInThisContext(require('module').wrap(file))(m.exports, m.require, m, path, require('path').dirname(path)); return m.exports; }; diff --git a/tests/test.js b/tests/test.js index 5ef84fe..7b9932d 100755 --- a/tests/test.js +++ b/tests/test.js @@ -2,7 +2,6 @@ var Templates = require('../index.js'); var _ = require('lodash'); var assert = require('chai').assert; var fs = require('fs'); - var asSync = Templates.asSync; var asAsync = Templates.asAsync; var Prototype = Templates.Prototype;