Skip to content

Commit 4babf12

Browse files
committed
fix(src): ignore unknown file extension errors when discovering commands
1 parent 4b8c975 commit 4babf12

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/discover.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,10 @@ export async function discoverCommands(
354354
maybeImportedConfig = await import(maybeConfigPath);
355355
} catch (error) {
356356
if (
357-
isModuleNotFoundSystemError(error) &&
358-
(error.moduleName?.endsWith(maybeConfigPath) ||
359-
error.url?.endsWith(maybeConfigPath))
357+
isUnknownFileExtensionError(error) ||
358+
(isModuleNotFoundSystemError(error) &&
359+
(error.moduleName?.endsWith(maybeConfigPath) ||
360+
error.url?.endsWith(maybeConfigPath)))
360361
) {
361362
debug_.warn(
362363
'a recoverable failure occurred while attempting to load configuration: %O',
@@ -1343,3 +1344,14 @@ function isModuleNotFoundSystemError(error: unknown): error is Error & {
13431344
(error.code === 'MODULE_NOT_FOUND' && 'moduleName' in error))
13441345
);
13451346
}
1347+
1348+
/**
1349+
* Type-guard for Node's "ERR_UNKNOWN_FILE_EXTENSION" so-called `SystemError`s.
1350+
*/
1351+
function isUnknownFileExtensionError(error: unknown): error is Error & {
1352+
code: 'ERR_UNKNOWN_FILE_EXTENSION';
1353+
} {
1354+
return (
1355+
isNativeError(error) && 'code' in error && error.code === 'ERR_UNKNOWN_FILE_EXTENSION'
1356+
);
1357+
}

0 commit comments

Comments
 (0)