Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit f415eeb

Browse files
committed
function:invoke不需要配置文件
1 parent 2c2140a commit f415eeb

5 files changed

Lines changed: 9 additions & 10 deletions

File tree

lib/commands/functions/invoke.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ async function invoke(ctx, jsonStringParams) {
4040
});
4141
}
4242
const func = functions.find(item => item.name === name);
43-
if (!func) {
44-
throw new error_1.CloudBaseError('未找到相关函数配置,请检查函数名是否正确');
45-
}
43+
const configParams = func && func.params ? func.params : undefined;
4644
const result = await function_1.invokeFunction({
4745
envId,
4846
functionName: name,
49-
params: params || func.params
47+
params: params || configParams
5048
});
5149
logger_1.successLog(`[${name}] 调用成功\n响应结果:\n`);
5250
console.log(result);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
exports.default = {
4-
functionRoot: './'
4+
functionRoot: './functions',
5+
functions: []
56
};

src/commands/functions/invoke.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ export async function invoke(ctx: FunctionContext, jsonStringParams: string) {
4646

4747
const func = functions.find(item => item.name === name)
4848

49-
if (!func) {
50-
throw new CloudBaseError('未找到相关函数配置,请检查函数名是否正确')
51-
}
49+
const configParams = func && func.params ? func.params : undefined
5250

5351
const result = await invokeFunction({
5452
envId,
5553
functionName: name,
56-
params: params || func.params
54+
params: params || configParams
5755
})
5856
successLog(`[${name}] 调用成功\n响应结果:\n`)
5957
console.log(result)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export default {
2-
functionRoot: './'
2+
functionRoot: './functions',
3+
functions: []
34
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
declare const _default: {
22
functionRoot: string;
3+
functions: any[];
34
};
45
export default _default;

0 commit comments

Comments
 (0)