From 2bf1ed95019f64136998047d741443e3c023a5ae Mon Sep 17 00:00:00 2001 From: Molunerfinn Date: Thu, 25 Jun 2020 16:20:53 +0800 Subject: [PATCH] :bug: Fix: the order of the uploaded list may not be the same as the order entered ISSUES CLOSED: #40 --- src/plugins/transformer/path.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 }