mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-11 16:26:20 +00:00
allow passing entire directories as input
This commit is contained in:
@@ -183,9 +183,14 @@ function progressTracker(results) {
|
||||
return tracker;
|
||||
}
|
||||
|
||||
async function checkInputFilesValid(files) {
|
||||
async function getInputFiles(paths) {
|
||||
const validFiles = [];
|
||||
|
||||
for (const path of paths) {
|
||||
//allow paths ending in / of \ to get all files in that directory
|
||||
const files = path.endsWith('/') || path.endsWith('\\')
|
||||
? await fs.readdir(paths)
|
||||
: [path];
|
||||
for (const file of files) {
|
||||
try {
|
||||
await fsp.stat(file);
|
||||
@@ -202,12 +207,13 @@ async function checkInputFilesValid(files) {
|
||||
|
||||
validFiles.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
return validFiles;
|
||||
}
|
||||
|
||||
async function processFiles(files) {
|
||||
files = await checkInputFilesValid(files);
|
||||
files = await getInputFiles(files);
|
||||
|
||||
const parallelism = cpus().length;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user