🔩 Tweaking filters

This commit is contained in:
2021-05-05 10:13:35 -07:00
parent 59567231a1
commit 82140a7e39
2 changed files with 20 additions and 18 deletions

View File

@@ -21,7 +21,7 @@ export const greet = async (
};
const fileObjects = await walkFolder("./comics");
const extractedDataPromises = _.map(fileObjects, async (fileObject) => {
{
if (SUPPORTED_COMIC_ARCHIVES.includes(fileObject.extension)) {
return await extractCoverFromComicBookArchive({
...targetOptions,
@@ -30,7 +30,5 @@ export const greet = async (
});
}
});
Promise.all(extractedDataPromises).then((data) => {
console.log(data);
});
};

View File

@@ -149,17 +149,6 @@ export const unrar = async (
}
};
export const extractMetadataFromImage = async (
imageFilePath: string,
): Promise<unknown> => {
const image = await sharp(imageFilePath)
.metadata()
.then(function (metadata) {
return metadata;
});
return image;
};
export const unzip = async (
extractionOptions: IExtractionOptions,
walkedFolder: IFolderData,
@@ -227,7 +216,7 @@ export const extractArchive = async (
return {
message: "File format not supported, yet.",
errorCode: "90",
data: "asda",
data: `${extractionOptions}`,
};
}
};
@@ -255,10 +244,11 @@ export const getCovers = async (
case "single":
return await extractArchive(options, walkedFolders[0]);
default:
logger.error("Unknown extraction mode selected.");
return {
message: "File format not supported, yet.",
message: "Unknown extraction mode selected.",
errorCode: "90",
data: "asda",
data: `${options}`,
};
}
};
@@ -285,6 +275,9 @@ export const walkFolder = async (folder: string): Promise<IFolderData[]> => {
return result;
};
const filterNonComicBookExtensions = (entities) => {
return entities.filter((entity) => entity.extname)
}
export const explodePath = (filePath: string): IExplodedPathResponse => {
const exploded = filePath.split("/");
const fileName = remove(exploded, (item) => {
@@ -311,3 +304,14 @@ const constructPaths = (
walkedFolder.extension,
};
};
export const extractMetadataFromImage = async (
imageFilePath: string,
): Promise<unknown> => {
const image = await sharp(imageFilePath)
.metadata()
.then(function (metadata) {
return metadata;
});
return image;
};