Skip to content

Commit 4597f22

Browse files
committed
refactoring done
1 parent 902f664 commit 4597f22

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)
22
[![npm version](https://badge.fury.io/js/serverless-step-functions-offline.svg)](https://badge.fury.io/js/serverless-step-functions-offline)
33
[![Known Vulnerabilities](https://snyk.io/test/github/vkkis93/serverless-step-functions-offline/badge.svg?targetFile=package.json)](https://snyk.io/test/github/vkkis93/serverless-step-functions-offline?targetFile=package.json)
4+
[![Dependency Status](https://david-dm.org/vkkis93/serverless-step-functions-offline.svg)](https://david-dm.org/vkkis93/serverless-step-functions-offline)
45

56
# serverless-step-functions-offline
67

@@ -114,9 +115,7 @@ By default `process.env.STEP_IS_OFFLINE = true`.
114115
- [x] Support context object
115116
- [x] Improve performance
116117
- [x] Fixing bugs
117-
- [x] Make code readable and supportable
118118
- [ ] Add unit tests - to make plugin stable (next step)
119-
120119
- [ ] Support fields *Retry*, *Catch*
121120
- [ ] Support other languages except node.js
122121

build.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ module.exports = {
4646
this.eventForParallelExecution = event;
4747
}
4848
const data = this._findStep(state, stateName);
49-
if (!data || data instanceof Promise) {
50-
return data;
51-
}
49+
if (!data || data instanceof Promise) {return data;}
5250
if (data.choice) {
5351
return this._runChoice(data, event);
5452
} else {
@@ -58,9 +56,7 @@ module.exports = {
5856

5957
_findStep(currentState, currentStateName) {
6058
// it means end of states
61-
if (!currentState) {
62-
return;
63-
}
59+
if (!currentState) {return;}
6460
this.currentState = currentState;
6561
return this._switcherByType(currentState, currentStateName);
6662
},
@@ -83,12 +79,15 @@ module.exports = {
8379
f: () => require(path.join(process.cwd(), this.variables[currentStateName].filePath))[this.variables[currentStateName].handler]
8480
};
8581
case 'Parallel': // look through branches and push all of them
82+
this.eventParallelResult = [];
8683
_.forEach(currentState.Branches, (branch) => {
8784
this.parallelBranch = branch;
8885
return this.process(branch.States[branch.StartAt], branch.StartAt, this.eventForParallelExecution);
8986
});
87+
this.process(this.states[currentState.Next], currentState.Next, this.eventParallelResult);
9088
delete this.parallelBranch;
91-
return this.process(this.states[currentState.Next], currentState.Next);
89+
delete this.eventParallelResult;
90+
return;
9291
case 'Choice':
9392
//push all choices. but need to store information like
9493
// 1) on which variable need to look: ${variable}
@@ -221,6 +220,7 @@ module.exports = {
221220
let state = this.states;
222221
if (this.parallelBranch && this.parallelBranch.States) {
223222
state = this.parallelBranch.States;
223+
if (!this.currentState.Next) this.eventParallelResult.push(result); //it means the end of execution of branch
224224
}
225225
this.process(state[this.currentState.Next], this.currentState.Next, result);
226226
});

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"lint": "eslint ./** --ext .js"
1212
},
1313
"keywords": [
14+
"aws",
15+
"lambda",
1416
"serverless",
1517
"step functions",
1618
"serverless-step-functions-offline"

0 commit comments

Comments
 (0)