Skip to content

Commit

Permalink
🐛 Fix: compatibility with auto-delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuingsmile committed Apr 18, 2023
1 parent 2ffac40 commit f9248d5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/core/Lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<IBuildInCompressOptions>('buildIn.compress')
const watermarkOptions = ctx.getConfig<IBuildInWaterMarkOptions>('buildIn.watermark')
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/PicGo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand All @@ -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'),
Expand Down
6 changes: 5 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
1 change: 1 addition & 0 deletions src/utils/createContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f9248d5

Please sign in to comment.