limit cli only to jpgs/pngs (by default)
This commit is contained in:
parent
eb455e2311
commit
e9bc9f568d
1 changed files with 7 additions and 3 deletions
10
cli/main.ts
10
cli/main.ts
|
@ -20,13 +20,17 @@ const args = parse(Deno.args, {
|
|||
});
|
||||
|
||||
const files: string[] = [];
|
||||
const includeExtensions = Array.from(
|
||||
String(args["include"] || "*.png, *.jpg").matchAll(/\*\.([\w]+)/g),
|
||||
).map(([_, group]) => group);
|
||||
|
||||
args["_"].forEach((arg) => {
|
||||
arg = arg.toString();
|
||||
if (Deno.statSync(arg).isDirectory) {
|
||||
Array.from(Deno.readDirSync(arg)).forEach((entry) =>
|
||||
files.push(`${arg}/${entry.name}`)
|
||||
);
|
||||
Array.from(Deno.readDirSync(arg)).filter((entry) =>
|
||||
includeExtensions.length == 0 ||
|
||||
includeExtensions.some((ext) => entry.name.endsWith(ext))
|
||||
).forEach((entry) => files.push(`${arg}/${entry.name}`));
|
||||
} else {
|
||||
files.push(arg);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue