Skip to content

Commit 79c228b

Browse files
committed
🐛 Fix: output empty after uploading when using isolate context
1 parent a0fbe68 commit 79c228b

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/core/Lifecycle.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ class Lifecycle extends EventEmitter {
9898
let msg = ''
9999
const length = ctx.output.length
100100
for (let i = 0; i < length; i++) {
101-
msg += handleUrlEncode(ctx.output[i].imgUrl)
102-
if (i !== length - 1) {
103-
msg += '\n'
101+
if (typeof ctx.output[i].imgUrl !== 'undefined') {
102+
msg += handleUrlEncode(ctx.output[i].imgUrl!)
103+
if (i !== length - 1) {
104+
msg += '\n'
105+
}
104106
}
105107
delete ctx.output[i].base64Image
106108
delete ctx.output[i].buffer

src/core/PicGo.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,17 @@ class PicGo extends EventEmitter implements IPicGo {
197197
fs.remove(imgPath).catch((e) => { this.log.error(e) })
198198
}
199199
})
200-
await this.lifecycle.start([imgPath])
201-
return this.output
200+
const { output } = await this.lifecycle.start([imgPath])
201+
return output
202202
}
203203
} catch (e) {
204204
this.emit(IBuildInEvent.FAILED, e)
205205
throw e
206206
}
207207
} else {
208208
// upload from path
209-
await this.lifecycle.start(input)
210-
return this.output
209+
const { output } = await this.lifecycle.start(input)
210+
return output
211211
}
212212
}
213213
}

src/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ interface IImgInfo {
173173
width?: number
174174
height?: number
175175
extname?: string
176+
imgUrl?: string
176177
[propName: string]: any
177178
}
178179

0 commit comments

Comments
 (0)