Skip to content

Commit c0bea6c

Browse files
authored
Update index.js
1 parent beca296 commit c0bea6c

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,22 @@ function dedupeNonExistent(nonExistent) {
198198

199199
// If the file is in a node module, use the root directory of the module
200200
function getDirectory(localConfig) {
201-
function _getProjectPath(filename) {
202-
try {
203-
const nodeModuleParts = filename.split('node_modules');
204-
const packageSubPathPath = nodeModuleParts.pop().split(path.sep).filter(Boolean);
205-
const packageName = packageSubPathPath[0].startsWith('@') ? `${packageSubPathPath[0]}${path.sep}${packageSubPathPath[1]}` : packageSubPathPath[0];
206-
207-
return path.normalize([...nodeModuleParts, `${path.sep}${packageName}`].join('node_modules'));
208-
} catch {
209-
debug(`Could not determine the root directory of package file ${filename}. Using default`);
210-
return null;
211-
}
212-
}
213-
214201
if (!localConfig.filename.includes('node_modules')) {
215202
return localConfig.directory;
216203
}
217204

218-
return _getProjectPath(path.dirname(localConfig.filename)) || localConfig.directory;
205+
return getProjectPath(path.dirname(localConfig.filename)) || localConfig.directory;
206+
}
207+
208+
function getProjectPath(filename) {
209+
try {
210+
const nodeModuleParts = filename.split('node_modules');
211+
const packageSubPathPath = nodeModuleParts.pop().split(path.sep).filter(Boolean);
212+
const packageName = packageSubPathPath[0].startsWith('@') ? `${packageSubPathPath[0]}${path.sep}${packageSubPathPath[1]}` : packageSubPathPath[0];
213+
214+
return path.normalize([...nodeModuleParts, `${path.sep}${packageName}`].join('node_modules'));
215+
} catch {
216+
debug(`Could not determine the root directory of package file ${filename}. Using default`);
217+
return null;
218+
}
219219
}

0 commit comments

Comments
 (0)