Skip to content

Commit

Permalink
assert: lazy load acorn
Browse files Browse the repository at this point in the history
This makes sure acorn is only loaded in case it is necessary.

PR-URL: #19863
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR committed Apr 9, 2018
1 parent 252eb2d commit 9c06770
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const {
}
} = require('internal/errors');
const { openSync, closeSync, readSync } = require('fs');
const { parseExpressionAt } = require('internal/deps/acorn/dist/acorn');
const { inspect } = require('util');
const { EOL } = require('os');
const { NativeModule } = require('internal/bootstrap/loaders');
Expand Down Expand Up @@ -173,6 +172,8 @@ function getErrMessage(call) {
fd = openSync(filename, 'r', 0o666);
const buffers = getBuffer(fd, line);
const code = Buffer.concat(buffers).toString('utf8');
// Lazy load acorn.
const { parseExpressionAt } = require('internal/deps/acorn/dist/acorn');
const nodes = parseExpressionAt(code, column);
// Node type should be "CallExpression" and some times
// "SequenceExpression".
Expand Down

0 comments on commit 9c06770

Please sign in to comment.