Skip to content

Commit

Permalink
lib,test: fix error message check after V8 update
Browse files Browse the repository at this point in the history
Backport-PR-URL: #29241
PR-URL: #28918
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
targos committed Sep 19, 2019
1 parent 027dcff commit 91d99ce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function enrichCJSError(err) {
usage. However, some cases are not matching, cases like import statement
after a comment block and/or after a variable definition.
*/
if (err.message.startsWith('Unexpected token export') ||
if (err.message.startsWith('Unexpected token \'export\'') ||
(/^\s*import(?=[ {'"*])\s*(?![ (])/).test(lineWithErr)) {
process.emitWarning(
'To load an ES module, set "type": "module" in the package.json or use ' +
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-v8-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ assert(vm.runInThisContext('%_IsSmi(43)'));

v8.setFlagsFromString('--noallow_natives_syntax');
assert.throws(function() { eval('%_IsSmi(44)'); },
/^SyntaxError: Unexpected token %$/);
/^SyntaxError: Unexpected token '%'$/);
assert.throws(function() { vm.runInThisContext('%_IsSmi(45)'); },
/^SyntaxError: Unexpected token %$/);
/^SyntaxError: Unexpected token '%'$/);
2 changes: 1 addition & 1 deletion test/parallel/test-vm-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const vm = require('vm');
);
}, {
type: SyntaxError,
message: 'Unexpected token }'
message: "Unexpected token '}'"
});

// Tests for failed argument validation
Expand Down

0 comments on commit 91d99ce

Please sign in to comment.