Skip to content

Commit

Permalink
only&ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jan 21, 2024
1 parent 2ac7669 commit 0341adb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/swc/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export default async function ({

for (const filename of await globSources(
cliOptions.filenames,
cliOptions.only,
cliOptions.ignore,
cliOptions.includeDotfiles
)) {
if (isCompilableExtension(filename, cliOptions.extensions)) {
Expand Down
9 changes: 8 additions & 1 deletion src/swc/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import glob from "fast-glob";
import slash from "slash";
import { stat } from "fs";
import { join, basename, extname } from "path";
import { minimatch } from "minimatch";

/**
* Find all input files based on source globs
Expand Down Expand Up @@ -42,7 +43,13 @@ export async function globSources(
})
);

return Array.from(new Set<string>(files.flat()));
const f = files.flat().filter(filename => {
return (
only.length === 0 || only.some(only => minimatch(slash(filename), only))
);
});

return Array.from(new Set<string>(f));
}

type Split = [compilable: string[], copyable: string[]];
Expand Down

0 comments on commit 0341adb

Please sign in to comment.