🪒 Shaved off some unused imports
This commit is contained in:
@@ -40,7 +40,7 @@ import { default as unzipper } from "unzipper";
|
|||||||
import { createReadStream, createWriteStream } from "fs";
|
import { createReadStream, createWriteStream } from "fs";
|
||||||
const { writeFile, readFile } = require("fs").promises;
|
const { writeFile, readFile } = require("fs").promises;
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import _ from "lodash";
|
import { each, isEmpty, map, remove, indexOf } from "lodash";
|
||||||
import { logger } from "./logger.utils";
|
import { logger } from "./logger.utils";
|
||||||
import {
|
import {
|
||||||
IExplodedPathResponse,
|
IExplodedPathResponse,
|
||||||
@@ -81,12 +81,12 @@ export const unrar = async (
|
|||||||
let fileNameToExtract = "";
|
let fileNameToExtract = "";
|
||||||
const list = extractor.getFileList();
|
const list = extractor.getFileList();
|
||||||
const fileHeaders = [...list.fileHeaders];
|
const fileHeaders = [...list.fileHeaders];
|
||||||
_.each(fileHeaders, async (fileHeader) => {
|
each(fileHeaders, async (fileHeader) => {
|
||||||
const fileName = explodePath(fileHeader.name).fileName;
|
const fileName = explodePath(fileHeader.name).fileName;
|
||||||
if (
|
if (
|
||||||
fileName !== "" &&
|
fileName !== "" &&
|
||||||
fileHeader.flags.directory === false &&
|
fileHeader.flags.directory === false &&
|
||||||
_.isEmpty(fileNameToExtract)
|
isEmpty(fileNameToExtract)
|
||||||
) {
|
) {
|
||||||
logger.info(`Attempting to write ${fileHeader.name}`);
|
logger.info(`Attempting to write ${fileHeader.name}`);
|
||||||
fileNameToExtract = fileHeader.name;
|
fileNameToExtract = fileHeader.name;
|
||||||
@@ -244,15 +244,22 @@ export const getCovers = async (
|
|||||||
| IExtractComicBookCoverErrorResponse
|
| IExtractComicBookCoverErrorResponse
|
||||||
| IExtractedComicBookCoverFile[]
|
| IExtractedComicBookCoverFile[]
|
||||||
)[]
|
)[]
|
||||||
|
| IExtractComicBookCoverErrorResponse
|
||||||
> => {
|
> => {
|
||||||
switch (options.extractionMode) {
|
switch (options.extractionMode) {
|
||||||
case "bulk":
|
case "bulk":
|
||||||
const extractedDataPromises = _.map(walkedFolders, async (folder) => {
|
const extractedDataPromises = map(walkedFolders, async (folder) => {
|
||||||
return await extractArchive(options, folder);
|
return await extractArchive(options, folder);
|
||||||
});
|
});
|
||||||
return Promise.all(extractedDataPromises).then((data) => data);
|
return Promise.all(extractedDataPromises).then((data) => data);
|
||||||
case "single":
|
case "single":
|
||||||
return await extractArchive(options, walkedFolders[0]);
|
return await extractArchive(options, walkedFolders[0]);
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
message: "File format not supported, yet.",
|
||||||
|
errorCode: "90",
|
||||||
|
data: "asda",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -280,8 +287,8 @@ export const walkFolder = async (folder: string): Promise<IFolderData[]> => {
|
|||||||
|
|
||||||
export const explodePath = (filePath: string): IExplodedPathResponse => {
|
export const explodePath = (filePath: string): IExplodedPathResponse => {
|
||||||
const exploded = filePath.split("/");
|
const exploded = filePath.split("/");
|
||||||
const fileName = _.remove(exploded, (item) => {
|
const fileName = remove(exploded, (item) => {
|
||||||
return _.indexOf(exploded, item) === exploded.length - 1;
|
return indexOf(exploded, item) === exploded.length - 1;
|
||||||
}).join("");
|
}).join("");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user