mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
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 <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>
This commit is contained in:
1 file changed
+1
-6
+1
-6
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user