Skip to content

Commit

Permalink
tools: avoid using process.cwd in tools/lint-js
Browse files Browse the repository at this point in the history
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 gibfahn committed Dec 19, 2017
1 parent 2fb6515 commit 5aff3d2
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions tools/lint-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5aff3d2

Please sign in to comment.