Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 65cd03c

Browse filesBrowse files
evanlucasrvagg
authored andcommitted
src: wrap source before doing syntax check
This is to ensure that it is evaluated the same way it would be if it were to be run by node or required. Before, the following would pass if run by node, but fail if run via the syntax check flag: if (true) { return; } Now, this will pass the syntax check PR-URL: #3587 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent 1e98d90 commit 65cd03c
Copy full SHA for 65cd03c

File tree

Expand file treeCollapse file tree

3 files changed

+6
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+6
-0
lines changed
Open diff view settings
Collapse file

‎src/node.js‎

Copy file name to clipboardExpand all lines: src/node.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
var source = fs.readFileSync(filename, 'utf-8');
107107
// remove shebang and BOM
108108
source = internalModule.stripBOM(source.replace(/^\#\!.*/, ''));
109+
// wrap it
110+
source = Module.wrap(source);
109111
// compile the script, this will throw if it fails
110112
new vm.Script(source, {filename: filename, displayErrors: true});
111113
process.exit(0);
Collapse file
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (true) {
2+
return;
3+
}
Collapse file

‎test/parallel/test-cli-syntax.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cli-syntax.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var syntaxArgs = [
2020
'syntax/good_syntax',
2121
'syntax/good_syntax_shebang.js',
2222
'syntax/good_syntax_shebang',
23+
'syntax/illegal_if_not_wrapped.js'
2324
].forEach(function(file) {
2425
file = path.join(common.fixturesDir, file);
2526

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.