diff --git a/src/plugins/transformer/path.ts b/src/plugins/transformer/path.ts index b24675e..6880c83 100644 --- a/src/plugins/transformer/path.ts +++ b/src/plugins/transformer/path.ts @@ -9,7 +9,7 @@ import { IPathTransformedImgInfo, ImgInfo, ImgSize } from '../../utils/interface const handle = async (ctx: PicGo): Promise => { let results: ImgInfo[] = ctx.output - await Promise.all(ctx.input.map(async (item: string) => { + await Promise.all(ctx.input.map(async (item: string, index: number) => { let info: IPathTransformedImgInfo if (isUrl(item)) { info = await getURLFile(item) @@ -19,13 +19,13 @@ const handle = async (ctx: PicGo): Promise => { if (info.success) { try { const imgSize = getImgSize(ctx, info.buffer, item) - results.push({ + results[index] = { buffer: info.buffer, fileName: info.fileName, width: imgSize.width, height: imgSize.height, extname: info.extname - }) + } } catch (e) { ctx.log.error(e) } @@ -33,6 +33,8 @@ const handle = async (ctx: PicGo): Promise => { ctx.log.error(info.reason) } })) + // remove empty item + ctx.output = results.filter(item => item) return ctx }