🚥 Added image file extension validator

This commit is contained in:
2021-07-13 06:39:42 -07:00
parent 3ee483dc91
commit f14800ffc2
2 changed files with 18 additions and 3 deletions

View File

@@ -9,7 +9,9 @@ import {
IFolderData,
} from "../interfaces/folder.interface";
import { logger } from "./logger.utils";
import { each, isEmpty, map, remove, indexOf } from "lodash";
import { includes, remove, indexOf } from "lodash";
const ALLOWED_IMAGE_FILE_FORMATS = [".jpg", ".jpeg", ".png"];
export const walkFolder = async (folder: string): Promise<IFolderData[]> => {
const result: IFolderData[] = [];
@@ -57,6 +59,10 @@ export const explodePath = (filePath: string): IExplodedPathResponse => {
};
};
export const isValidImageFileExtension = (fileName: string): boolean => {
return includes(ALLOWED_IMAGE_FILE_FORMATS, path.extname(fileName));
};
export const constructPaths = (
extractionOptions: IExtractionOptions,
walkedFolder: IFolderData