Skip to content

Commit

Permalink
Ensuring an error is thrown if no files are found, but only if no fil…
Browse files Browse the repository at this point in the history
…es were ignored also
  • Loading branch information
fabiospampinato committed Sep 15, 2024
1 parent 4207534 commit d4d7eca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async function runGlobs(options: Options, pluginsDefaultOptions: PluginsOptions,
stdout.prefixed.debug(`Files errored: ${totalErrored}`);
stdout.prefixed.debug(() => pathsErrored.map((filePath) => fastRelativePath(rootPath, filePath)).join("\n"));

if (!totalMatched) {
if (!totalMatched && !totalIgnored) {
if (options.errorOnUnmatchedPattern) {
stderr.prefixed.error(`No files matching the given patterns were found`);
}
Expand All @@ -223,7 +223,7 @@ async function runGlobs(options: Options, pluginsDefaultOptions: PluginsOptions,

cache?.write();

process.exitCode = (!totalMatched && options.errorOnUnmatchedPattern) || totalErrored || (totalUnformatted && !options.write) ? 1 : 0;
process.exitCode = (!totalMatched && !totalIgnored && options.errorOnUnmatchedPattern) || totalErrored || (totalUnformatted && !options.write) ? 1 : 0;
}

export { run, runStdin, runGlobs };

0 comments on commit d4d7eca

Please sign in to comment.