Skip to content

Commit

Permalink
FIxed an issue where an input file could be processed twice in some e…
Browse files Browse the repository at this point in the history
…dge cases
  • Loading branch information
fabiospampinato committed Sep 14, 2024
1 parent 10652d7 commit 2cc594e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ async function getTargetsPaths(
}

const result = await getGlobPaths(rootPath, targetGlobs, withNodeModules);
const filesPaths = [...targetFiles, ...result.files];
const filesNames = [...targetFilesNames, ...result.filesFoundNames];
const resultFiles = result.files;
const resultFilesFoundNames = [...result.filesFoundNames];

const filesPaths = [...without(targetFiles, resultFiles), ...resultFiles];
const filesNames = [...without(targetFilesNames, resultFilesFoundNames), ...resultFilesFoundNames];
const filesNamesToPaths = result.filesFoundNamesToPaths;

for (const fileName in targetFilesNamesToPaths) {
Expand Down Expand Up @@ -637,6 +640,13 @@ function uniq<T>(values: T[]): T[] {
return Array.from(new Set(values));
}

function without<T>(values: T[], exclude: T[]): T[] {
if (!values.length) return values;
if (!exclude.length) return values;
const excludeSet = new Set(exclude);
return values.filter((value) => !excludeSet.has(value));
}

function zipObjectUnless<T extends Key, U>(keys: T[], values: U[], unless: (value: U) => boolean): Partial<Record<T, U>> {
const map: Partial<Record<T, U>> = {};

Expand Down Expand Up @@ -699,5 +709,6 @@ export {
someOf,
trimFinalNewline,
uniq,
without,
zipObjectUnless,
};

0 comments on commit 2cc594e

Please sign in to comment.