Skip to content

Commit b43cacd

Browse files
abetomoDeviaVir
authored andcommitted
Fix to set boolean in params.Publish (#346)
1 parent 09c2cd8 commit b43cacd

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@ Lambda.prototype._params = (program, buffer) => {
163163
Description: program.description,
164164
MemorySize: program.memorySize,
165165
Timeout: program.timeout,
166-
Publish: program.publish,
166+
Publish: (() => {
167+
if (typeof program.publish === 'boolean') {
168+
return program.publish
169+
}
170+
return program.publish === 'true'
171+
})(),
167172
VpcConfig: {
168173
SubnetIds: [],
169174
SecurityGroupIds: []

test/main.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,35 @@ describe('lib/main', function () {
222222
assert.isNull(params.TracingConfig.Mode)
223223
})
224224

225+
describe('params.Publish', () => {
226+
describe('boolean', () => {
227+
it('If true, it is set to true', () => {
228+
program.publish = true
229+
const params = lambda._params(program)
230+
assert.isTrue(params.Publish)
231+
})
232+
it('If false, it is set to false', () => {
233+
program.publish = false
234+
const params = lambda._params(program)
235+
assert.isFalse(params.Publish)
236+
})
237+
})
238+
239+
describe('string', () => {
240+
it('If "true", it is set to true', () => {
241+
program.publish = 'true'
242+
const params = lambda._params(program)
243+
assert.isTrue(params.Publish)
244+
})
245+
it('If not "true", it is set to false', () => {
246+
program.publish = 'false'
247+
assert.isFalse(lambda._params(program).Publish)
248+
program.publish = 'aaa'
249+
assert.isFalse(lambda._params(program).Publish)
250+
})
251+
})
252+
})
253+
225254
describe('configFile', () => {
226255
beforeEach(() => {
227256
// Prep...

0 commit comments

Comments
 (0)