Permalink
Browse files

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: #17121
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
tniessen authored and MylesBorins committed Nov 18, 2017
1 parent ca76c33 commit 466e94a6c1e67c3ff7c5b39485ba6cece5caff27
Showing with 1 addition and 6 deletions.
  1. +1 −6 tools/lint-js.js
View
@@ -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);

0 comments on commit 466e94a

Please sign in to comment.