Skip to content

Commit e0c323a

Browse files
committed
fix: add delete scf/apigw campatibility
1 parent 335f939 commit e0c323a

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/baas/apigw/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,16 @@ class Apigw {
551551

552552
async remove(inputs) {
553553
const { created, environment, serviceId, apiList, customDomains } = inputs
554+
// check service exist
555+
try {
556+
await this.request({
557+
Action: 'DescribeService',
558+
serviceId: serviceId
559+
})
560+
} catch (e) {
561+
console.log(`Service ${serviceId} not exist`)
562+
return
563+
}
554564
// 1. remove all apis
555565
for (let i = 0; i < apiList.length; i++) {
556566
const curApi = apiList[i]

src/baas/scf/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,18 @@ class Scf {
498498
// 移除函数的主逻辑
499499
async remove(inputs = {}) {
500500
console.log(`Deleteing funtion ${inputs.functionName || inputs.FunctionName} ...`)
501-
await this.deleteFunction(
502-
inputs.functionName || inputs.FunctionName,
503-
inputs.namespace || inputs.Namespace || defaultNamespace
504-
)
501+
const functionName = inputs.functionName || inputs.FunctionName
502+
const namespace = inputs.namespace || inputs.Namespace || defaultNamespace
503+
504+
// check function exist, then delete
505+
const func = await this.getFunction(functionName, namespace)
506+
507+
if (!func) {
508+
console.log(`Funtion ${functionName} not exist...`)
509+
return
510+
}
511+
512+
await this.deleteFunction(functionName, namespace)
505513

506514
if (inputs.Triggers) {
507515
for (let i = 0; i < inputs.Triggers.length; i++) {

0 commit comments

Comments
 (0)