Minor tweaks to previous PR commit.

This commit is contained in:
David Anson 2020-10-21 20:53:30 -07:00
parent 4bff44e33f
commit dd2c1d08ee
4 changed files with 9 additions and 5600 deletions

View file

@ -896,7 +896,7 @@ function parseConfiguration(name, content, parsers) {
/**
* Resolve referenced "extends" path in a configuration file
* using path.resolve() and require.resolve() as a fallback.
* using path.resolve() with require.resolve() as a fallback.
*
* @param {string} configFile Configuration file name.
* @param {string} referenceId Referenced identifier to resolve.
@ -909,15 +909,13 @@ function resolveConfigExtends(configFile, referenceId) {
if (fs.statSync(resolvedExtendsFile).isFile()) {
return resolvedExtendsFile;
}
// eslint-disable-next-line unicorn/prefer-optional-catch-binding
} catch (error) {
// If fs.statSync has thrown, trying require.resolve
} catch {
// If not a file or fs.statSync throws, try require.resolve
}
try {
return require.resolve(referenceId, { "paths": [ configFileDirname ] });
// eslint-disable-next-line unicorn/prefer-optional-catch-binding
} catch (error) {
// If require.resolve throws, returning resolvedExtendsFile for BC
} catch {
// If require.resolve throws, return resolvedExtendsFile
}
return resolvedExtendsFile;
}