From f9248d52663a400b3a935d69d6cf92757b193e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E8=90=8C=E5=93=92=E8=B5=AB=E8=90=9D?= Date: Tue, 18 Apr 2023 19:24:50 +0800 Subject: [PATCH] :bug: Fix: compatibility with auto-delete --- src/core/Lifecycle.ts | 3 +++ src/core/PicGo.ts | 2 ++ src/types/index.ts | 6 +++++- src/utils/createContext.ts | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/Lifecycle.ts b/src/core/Lifecycle.ts index b69bebf..a3bd323 100644 --- a/src/core/Lifecycle.ts +++ b/src/core/Lifecycle.ts @@ -6,6 +6,7 @@ import { createContext } from '../utils/createContext' import path from 'path' import fs from 'fs-extra' import axios from 'axios' +import { cloneDeep } from 'lodash' export class Lifecycle extends EventEmitter { private readonly ctx: IPicGo @@ -50,6 +51,7 @@ export class Lifecycle extends EventEmitter { throw new Error('Input must be an array.') } ctx.input = input + ctx.rawInput = cloneDeep(input) ctx.output = [] const compressOptions = ctx.getConfig('buildIn.compress') const watermarkOptions = ctx.getConfig('buildIn.watermark') @@ -139,6 +141,7 @@ export class Lifecycle extends EventEmitter { await this.doTransform(ctx) await this.beforeUpload(ctx) await this.doUpload(ctx) + ctx.input = ctx.rawInput await this.afterUpload(ctx) return ctx } catch (e: any) { diff --git a/src/core/PicGo.ts b/src/core/PicGo.ts index a42d1b3..30e8ec7 100644 --- a/src/core/PicGo.ts +++ b/src/core/PicGo.ts @@ -32,6 +32,7 @@ export class PicGo extends EventEmitter implements IPicGo { cmd: Commander output: IImgInfo[] input: any[] + rawInput: any[] pluginHandler: PluginHandler /** * @deprecated will be removed in v1.5.0+ @@ -52,6 +53,7 @@ export class PicGo extends EventEmitter implements IPicGo { this.configPath = configPath this.output = [] this.input = [] + this.rawInput = [] this.helper = { transformer: new LifecyclePlugins('transformer'), uploader: new LifecyclePlugins('uploader'), diff --git a/src/types/index.ts b/src/types/index.ts index 02d6c72..282f8b3 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -27,9 +27,13 @@ export interface IPicGo extends NodeJS.EventEmitter { */ output: IImgInfo[] /** - * the origin input + * the processed input */ input: any[] + /** + * the origin input + */ + rawInput: any[] /** * register\unregister\get picgo's plugin */ diff --git a/src/utils/createContext.ts b/src/utils/createContext.ts index f057ae1..c6e5ab0 100644 --- a/src/utils/createContext.ts +++ b/src/utils/createContext.ts @@ -12,6 +12,7 @@ export const createContext = (ctx: IPicGo): IPicGo => { cmd: ctx.cmd, output: [], input: [], + rawInput: [], pluginLoader: ctx.pluginLoader, pluginHandler: ctx.pluginHandler, Request: ctx.Request,