diff --git a/src/node.js b/src/node.js index 7cfd2c035962a6..1aa489b79dee6d 100644 --- a/src/node.js +++ b/src/node.js @@ -104,6 +104,8 @@ var source = fs.readFileSync(filename, 'utf-8'); // remove shebang and BOM source = internalModule.stripBOM(source.replace(/^\#\!.*/, '')); + // wrap it + source = Module.wrap(source); // compile the script, this will throw if it fails new vm.Script(source, {filename: filename, displayErrors: true}); process.exit(0); diff --git a/test/fixtures/syntax/illegal_if_not_wrapped.js b/test/fixtures/syntax/illegal_if_not_wrapped.js new file mode 100644 index 00000000000000..d76a836c882b23 --- /dev/null +++ b/test/fixtures/syntax/illegal_if_not_wrapped.js @@ -0,0 +1,3 @@ +if (true) { + return; +} diff --git a/test/parallel/test-cli-syntax.js b/test/parallel/test-cli-syntax.js index 20fdfdc995acbb..1118a63934d747 100644 --- a/test/parallel/test-cli-syntax.js +++ b/test/parallel/test-cli-syntax.js @@ -20,6 +20,7 @@ var syntaxArgs = [ 'syntax/good_syntax', 'syntax/good_syntax_shebang.js', 'syntax/good_syntax_shebang', + 'syntax/illegal_if_not_wrapped.js' ].forEach(function(file) { file = path.join(common.fixturesDir, file);