tools: fix eslint usage for Node.js 8 and before

IDEs like vscode use older Node.js versions that do not yet support
the new try catch syntax. This makes sure eslint continues to work
in these IDEs as before.

PR-URL: https://github.com/nodejs/node/pull/24753
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Ruben Bridgewater 2018-11-30 17:35:55 +01:00
parent 2b5f2bc68b
commit 5f18991f27
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -17,7 +17,10 @@ Module._findPath = (request, paths, isMain) => {
if (!r && hacks.includes(request)) {
try {
return require.resolve(`./tools/node_modules/${request}`);
} catch {
// Keep the variable in place to ensure that ESLint started by older Node.js
// versions work as expected.
// eslint-disable-next-line no-unused-vars
} catch (e) {
return require.resolve(
`./tools/node_modules/eslint/node_modules/${request}`);
}