From 34bfbfece465567381262e22a5a35a7244916d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 18 Nov 2017 19:15:20 +0100 Subject: [PATCH] tools: avoid using process.cwd in tools/lint-js The first occurrence of path.join() can easily be replaced with path.resolve(). The second occurrence should be unnecessary as ESLint will resolve the path internally, and the old check probably did not work as intended anyway. PR-URL: https://github.com/nodejs/node/pull/17121 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- tools/lint-js.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/lint-js.js b/tools/lint-js.js index 202f0f062d5330..a22fb9439c7e06 100644 --- a/tools/lint-js.js +++ b/tools/lint-js.js @@ -13,7 +13,6 @@ const totalCPUs = require('os').cpus().length; const CLIEngine = require('./eslint').CLIEngine; const glob = require('./eslint/node_modules/glob'); -const cwd = process.cwd(); const cliOptions = { rulePaths: rulesDirs, extensions: extensions, @@ -82,9 +81,7 @@ if (cluster.isMaster) { if (i !== -1) { if (!process.argv[i + 1]) throw new Error('Missing output filename'); - var outPath = process.argv[i + 1]; - if (!path.isAbsolute(outPath)) - outPath = path.join(cwd, outPath); + const outPath = path.resolve(process.argv[i + 1]); fd = fs.openSync(outPath, 'w'); outFn = function(str) { fs.writeSync(fd, str, 'utf8'); @@ -176,8 +173,6 @@ if (cluster.isMaster) { while (paths.length) { var dir = paths.shift(); curPath = dir; - if (dir.indexOf('/') > 0) - dir = path.join(cwd, dir); const patterns = cli.resolveFileGlobPatterns([dir]); dir = path.resolve(patterns[0]); files = glob.sync(dir, globOptions);