Skip to content

Commit

Permalink
fixed the bug that events array does not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
horike37 committed Apr 17, 2017
1 parent acaf689 commit e5db993
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
36 changes: 20 additions & 16 deletions lib/index.js
Expand Up @@ -135,25 +135,29 @@ class ServerlessStepFunctions {
const endpointInfo = this.endpointInfo;
message += `${chalk.yellow.underline('Serverless StepFunctions OutPuts')}\n`;
message += `${chalk.yellow('endpoints:')}`;
_.forEach(this.getAllStateMachines(), (stateMachineName) => {
const stateMachineObj = this.getStateMachine(stateMachineName);
stateMachineObj.events.forEach(event => {
if (event.http) {
let method;
let path;
if (this.isStateMachines()) {
_.forEach(this.getAllStateMachines(), (stateMachineName) => {
const stateMachineObj = this.getStateMachine(stateMachineName);
if (stateMachineObj.events != null && _.isArray(stateMachineObj.events)) {
stateMachineObj.events.forEach(event => {
if (event.http) {
let method;
let path;

if (typeof event.http === 'object') {
method = event.http.method.toUpperCase();
path = event.http.path;
} else {
method = event.http.split(' ')[0].toUpperCase();
path = event.http.split(' ')[1];
}
path = path !== '/' ? `/${path.split('/').filter(p => p !== '').join('/')}` : '';
message += `\n ${method} - ${endpointInfo}${path}`;
if (typeof event.http === 'object') {
method = event.http.method.toUpperCase();
path = event.http.path;
} else {
method = event.http.split(' ')[0].toUpperCase();
path = event.http.split(' ')[1];
}
path = path !== '/' ? `/${path.split('/').filter(p => p !== '').join('/')}` : '';
message += `\n ${method} - ${endpointInfo}${path}`;
}
});
}
});
});
}
message += '\n';
this.serverless.cli.consoleLog(message);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "serverless-step-functions",
"version": "1.0.1",
"version": "1.0.2",
"description": "The module is AWS Step Functions plugin for Serverless Framework",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit e5db993

Please sign in to comment.