Skip to content

Commit e5db993

Browse files
committed
fixed the bug that events array does not exists
1 parent acaf689 commit e5db993

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

lib/index.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,29 @@ class ServerlessStepFunctions {
135135
const endpointInfo = this.endpointInfo;
136136
message += `${chalk.yellow.underline('Serverless StepFunctions OutPuts')}\n`;
137137
message += `${chalk.yellow('endpoints:')}`;
138-
_.forEach(this.getAllStateMachines(), (stateMachineName) => {
139-
const stateMachineObj = this.getStateMachine(stateMachineName);
140-
stateMachineObj.events.forEach(event => {
141-
if (event.http) {
142-
let method;
143-
let path;
138+
if (this.isStateMachines()) {
139+
_.forEach(this.getAllStateMachines(), (stateMachineName) => {
140+
const stateMachineObj = this.getStateMachine(stateMachineName);
141+
if (stateMachineObj.events != null && _.isArray(stateMachineObj.events)) {
142+
stateMachineObj.events.forEach(event => {
143+
if (event.http) {
144+
let method;
145+
let path;
144146

145-
if (typeof event.http === 'object') {
146-
method = event.http.method.toUpperCase();
147-
path = event.http.path;
148-
} else {
149-
method = event.http.split(' ')[0].toUpperCase();
150-
path = event.http.split(' ')[1];
151-
}
152-
path = path !== '/' ? `/${path.split('/').filter(p => p !== '').join('/')}` : '';
153-
message += `\n ${method} - ${endpointInfo}${path}`;
147+
if (typeof event.http === 'object') {
148+
method = event.http.method.toUpperCase();
149+
path = event.http.path;
150+
} else {
151+
method = event.http.split(' ')[0].toUpperCase();
152+
path = event.http.split(' ')[1];
153+
}
154+
path = path !== '/' ? `/${path.split('/').filter(p => p !== '').join('/')}` : '';
155+
message += `\n ${method} - ${endpointInfo}${path}`;
156+
}
157+
});
154158
}
155159
});
156-
});
160+
}
157161
message += '\n';
158162
this.serverless.cli.consoleLog(message);
159163
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-step-functions",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "The module is AWS Step Functions plugin for Serverless Framework",
55
"main": "lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)