Skip to content

Commit e7c0281

Browse files
authored
executeAll bug fix in v1
1 parent d5276c2 commit e7c0281

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

index.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,7 @@ class ServerlessDynamodbLocal {
4444
}
4545
},
4646
executeAll: {
47-
lifecycleEvents: ['executeAllHandler'],
48-
options: {
49-
region: {
50-
shortcut: 'r',
51-
usage: 'Region that dynamodb should be remotely executed'
52-
},
53-
stage: {
54-
shortcut: 's',
55-
usage: 'Stage that dynamodb should be remotely executed'
56-
}
57-
}
47+
lifecycleEvents: ['executeAllHandler']
5848
},
5949
start: {
6050
lifecycleEvents: ['startHandler'],
@@ -97,7 +87,14 @@ class ServerlessDynamodbLocal {
9787
lifecycleEvents: ['removeHandler']
9888
},
9989
install: {
100-
lifecycleEvents: ['installHandler']
90+
lifecycleEvents: ['installHandler'],
91+
options: {
92+
localPath: {
93+
shortcut: 'x',
94+
usage: 'Local dynamodb install path'
95+
}
96+
}
97+
10198
}
10299
}
103100
}
@@ -123,17 +120,21 @@ class ServerlessDynamodbLocal {
123120
});
124121
}
125122

126-
dynamodbOptions(stage, region) {
123+
dynamodbOptions(region) {
127124
let self = this;
128125
let credentials, config = self.service.custom.dynamodb || {},
129126
port = config.start && config.start.port || 8000,
130127
dynamoOptions;
131-
132-
dynamoOptions = {
128+
if(region){
129+
AWS.config.update({
130+
region: region
131+
});
132+
}else{
133+
dynamoOptions = {
133134
endpoint: 'http://localhost:' + port,
134135
region: 'localhost'
135136
};
136-
137+
}
137138
return {
138139
raw: new AWS.DynamoDB(dynamoOptions),
139140
doc: new AWS.DynamoDB.DocumentClient(dynamoOptions)
@@ -168,12 +169,11 @@ class ServerlessDynamodbLocal {
168169
}
169170

170171
executeAllHandler() {
171-
let self = this,
172-
options = this.options;
172+
let self = this;
173173
return new BbPromise(function(resolve, reject) {
174-
let dynamodb = self.dynamodbOptions(options.stage, options.region),
174+
let dynamodb = self.dynamodbOptions(self.service.provider.region),
175175
tableOptions = self.tableOptions();
176-
dynamodbMigrations.init(dynamodb, tableOptions.path);
176+
dynamodbMigrations.init(dynamodb, tableOptions.path);
177177
dynamodbMigrations.executeAll(tableOptions).then(resolve, reject);
178178
});
179179
}
@@ -185,8 +185,10 @@ class ServerlessDynamodbLocal {
185185
}
186186

187187
installHandler() {
188+
let self = this,
189+
options = this.options;
188190
return new BbPromise(function(resolve) {
189-
dynamodbLocal.install(resolve);
191+
dynamodbLocal.install(resolve, options.localPath);
190192
});
191193
}
192194

0 commit comments

Comments
 (0)