Skip to content

Commit a89115a

Browse files
authored
Update stage and region handling (#3)
* Add tests * Update stage and region handling
1 parent 3b7b89b commit a89115a

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ package:
7575
7676
custom:
7777
output:
78-
handler: scripts/output.handle
78+
handler: scripts/output.handler
7979
file: .build/stack.toml
8080
8181
provider:

src/plugin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Plugin {
2424
}
2525

2626
get stackName () {
27-
return this.serverless.service.service + '-' + this.options.stage
27+
return this.serverless.service.service + '-' + this.serverless.getProvider('aws').getStage()
2828
}
2929

3030
hasConfig (key) {
@@ -71,8 +71,8 @@ class Plugin {
7171
{
7272
StackName: this.stackName
7373
},
74-
this.options.stage,
75-
this.options.region
74+
this.serverless.getProvider('aws').getStage(),
75+
this.serverless.getProvider('aws').getRegion()
7676
)
7777
}
7878

test/plugin.spec.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ describe('Plugin', () => {
2525
describe('Configuration', () => {
2626
it('hasHandler', () => {
2727
const config = {
28+
config: {
29+
servicePath: ''
30+
},
2831
cli: { log: () => {} },
2932
region: 'us-east-1',
3033
service: {
@@ -44,12 +47,17 @@ describe('Plugin', () => {
4447

4548
expect(test.hasHandler()).toBe(true)
4649
expect(test.hasFile()).toBe(false)
50+
51+
expect(test.handler).toContain('foo/bar.baz')
4752
})
4853
})
4954

5055
describe('Configuration', () => {
5156
it('hasFile', () => {
5257
const config = {
58+
config: {
59+
servicePath: ''
60+
},
5361
cli: { log: () => {} },
5462
region: 'us-east-1',
5563
service: {
@@ -58,7 +66,7 @@ describe('Plugin', () => {
5866
},
5967
custom: {
6068
output: {
61-
file: './foo/bar.toml'
69+
file: 'foo/bar.toml'
6270
}
6371
}
6472
},
@@ -69,6 +77,8 @@ describe('Plugin', () => {
6977

7078
expect(test.hasHandler()).toBe(false)
7179
expect(test.hasFile()).toBe(true)
80+
81+
expect(test.file).toContain('foo/bar.toml')
7282
})
7383
})
7484
})

0 commit comments

Comments
 (0)