Open
Description
Hi!
recently ran into an access issue when working with eslint-plugin-import and found this problem:
the file is in the dependency eslint-module-utils which seem to not have it's own repo but is linked to this project
The file is resolve.js
here to check if a directory exists the code tries to access a list of files in its parent dir and then find parsedPath.base in received list. This makes an issue when script executor doesn't have access to the directory above
const parsedPath = path.parse(filepath);
const dir = parsedPath.dir;
let result = fileExistsCache.get(filepath, cacheSettings);
if (result != null) return result;
// base case
if (dir === '' || parsedPath.root === filepath) {
result = true;
} else {
const filenames = fs.readdirSync(dir);
if (filenames.indexOf(parsedPath.base) === -1) {
result = false;
} else {
result = fileExistsWithCaseSync(dir, cacheSettings, strict);
}
}
The same functionality can be implemented this way:
if (dir === '' || parsedPath.root === filepath) {
result = true;
} else {
if (!fs.existsSync(path.join(dir, parsedPath.base))) {
result = false;
} else {
result = fileExistsWithCaseSync(dir, cacheSettings, strict);
}
}