Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Commit 132c48c

Browse files
committed
fix dangling variable parsing
1 parent 6a6b9b8 commit 132c48c

28 files changed

+144
-128
lines changed

lib/util/args.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pgb-cli",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "nodeJS CLI to PhoneGap Build",
55
"keywords": [
66
"PhoneGap",

src/util/args.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = (opts) => {
2828
if (variable) {
2929
let value = (args.length) ? args.join('=') : rawArgs[++i]
3030
if (opts.variables[key]) {
31-
variables[key] = (variables[key] || []).concat(value.split(','))
31+
variables[key] = (variables[key] || []).concat((value || '').split(','))
3232
} else {
3333
variables[key] = value
3434
}

test/commands/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('app', () => {
2222
.then(command)
2323
.then(() => {
2424
expect(validators.args).toHaveBeenLastCalledWith(1)
25-
expect(validators.signed_in).toBeCalled()
25+
expect(validators.signed_in).toHaveBeenCalled()
2626
expect(validators.id).toHaveBeenLastCalledWith('12')
2727
})
2828
})
@@ -31,7 +31,7 @@ describe('app', () => {
3131
return Promise.resolve()
3232
.then(command)
3333
.then((app) => {
34-
expect(pgb.print).toBeCalledWith({ 'bare': 12, 'json': { 'id': 12 }, 'pretty': { 'id': 12 } })
34+
expect(pgb.print).toHaveBeenCalledWith({ 'bare': 12, 'json': { 'id': 12 }, 'pretty': { 'id': 12 } })
3535
})
3636
})
3737

@@ -49,6 +49,6 @@ describe('app', () => {
4949
test('should support completion', () =>
5050
Promise.resolve()
5151
.then(command.completion)
52-
.then(() => expect(complete.app).toBeCalled())
52+
.then(() => expect(complete.app).toHaveBeenCalled())
5353
)
5454
})

test/commands/build.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('build', () => {
2222
return Promise.resolve()
2323
.then(command)
2424
.then(() => {
25-
expect(validators.signed_in).toBeCalled()
25+
expect(validators.signed_in).toHaveBeenCalled()
2626
expect(validators.args).toHaveBeenLastCalledWith(1)
2727
expect(validators.platform).toHaveBeenCalledTimes(2)
2828
expect(validators.id).toHaveBeenLastCalledWith('12')
@@ -33,9 +33,9 @@ describe('build', () => {
3333
return Promise.resolve()
3434
.then(command)
3535
.then((cmd) => {
36-
expect(pgb.api.buildApp).toBeCalledWith('12', [''])
37-
expect(wait).toBeCalledWith({ id: 12 })
38-
expect(pgb.print).toBeCalledWith({ 'bare': 12, 'json': { 'id': 12, 'wait': true } })
36+
expect(pgb.api.buildApp).toHaveBeenCalledWith('12', [''])
37+
expect(wait).toHaveBeenCalledWith({ id: 12 })
38+
expect(pgb.print).toHaveBeenCalledWith({ 'bare': 12, 'json': { 'id': 12, 'wait': true } })
3939
})
4040
})
4141

@@ -44,9 +44,9 @@ describe('build', () => {
4444
return Promise.resolve()
4545
.then(command)
4646
.then((cmd) => {
47-
expect(pgb.api.buildApp).toBeCalledWith('12', ['ios'])
48-
expect(wait).toBeCalledWith({ id: 12 })
49-
expect(pgb.print).toBeCalledWith({ 'bare': 12, 'json': { 'id': 12, 'wait': true } })
47+
expect(pgb.api.buildApp).toHaveBeenCalledWith('12', ['ios'])
48+
expect(wait).toHaveBeenCalledWith({ id: 12 })
49+
expect(pgb.print).toHaveBeenCalledWith({ 'bare': 12, 'json': { 'id': 12, 'wait': true } })
5050
})
5151
})
5252

@@ -55,9 +55,9 @@ describe('build', () => {
5555
return Promise.resolve()
5656
.then(command)
5757
.then((cmd) => {
58-
expect(pgb.api.buildApp).toBeCalledWith('12', ['ios', 'winphone', 'android'])
59-
expect(wait).toBeCalledWith({ id: 12 })
60-
expect(pgb.print).toBeCalledWith({ 'bare': 12, 'json': { 'id': 12, 'wait': true } })
58+
expect(pgb.api.buildApp).toHaveBeenCalledWith('12', ['ios', 'winphone', 'android'])
59+
expect(wait).toHaveBeenCalledWith({ id: 12 })
60+
expect(pgb.print).toHaveBeenCalledWith({ 'bare': 12, 'json': { 'id': 12, 'wait': true } })
6161
})
6262
})
6363

@@ -75,6 +75,6 @@ describe('build', () => {
7575
test('should support completion', () =>
7676
Promise.resolve()
7777
.then(command.completion)
78-
.then(() => expect(complete.appAndPlatform).toBeCalled())
78+
.then(() => expect(complete.appAndPlatform).toHaveBeenCalled())
7979
)
8080
})

test/commands/completion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('build', () => {
6565
.then(command)
6666
.then(() => {
6767
expect(console.log).not.toHaveBeenCalledWith('')
68-
expect(pgb.debug).toBeCalledWith(new Error('an error'))
68+
expect(pgb.debug).toHaveBeenCalledWith(new Error('an error'))
6969
})
7070
})
7171

test/commands/download.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('download', () => {
2121
.then(command)
2222
.then(() => {
2323
expect(validators.args).toHaveBeenLastCalledWith(2)
24-
expect(validators.signed_in).toBeCalled()
24+
expect(validators.signed_in).toHaveBeenCalled()
2525
expect(validators.platform).toHaveBeenLastCalledWith('ios', true)
2626
})
2727
})
@@ -30,7 +30,7 @@ describe('download', () => {
3030
return Promise.resolve()
3131
.then(command)
3232
.then(() => {
33-
expect(pgb.api.downloadApp).toBeCalledWith('12', 'ios', '.')
33+
expect(pgb.api.downloadApp).toHaveBeenCalledWith('12', 'ios', '.')
3434
})
3535
})
3636

@@ -39,7 +39,7 @@ describe('download', () => {
3939
return Promise.resolve()
4040
.then(command)
4141
.then(() => {
42-
expect(pgb.api.downloadApp).toBeCalledWith('12', 'ios', '/foo')
42+
expect(pgb.api.downloadApp).toHaveBeenCalledWith('12', 'ios', '/foo')
4343
})
4444
})
4545

@@ -53,14 +53,14 @@ describe('download', () => {
5353
return Promise.resolve()
5454
.then(command)
5555
.then(() => {
56-
expect(pgb.print).not.toBeCalled()
56+
expect(pgb.print).not.toHaveBeenCalled()
5757
let call = pgb.api.downloadApp.mock.calls[0]
5858
expect(call[0]).toBe('12')
5959
expect(call[1]).toBe('ios')
6060
expect(call[2]).toBeInstanceOf(require('stream').Writable)
6161
expect(call[2]).toMatchObject({ _isStdio: true })
62-
expect(Progress).not.toBeCalledWith('downloading ', 100, 60)
63-
expect(pgb.print).not.toBeCalled()
62+
expect(Progress).not.toHaveBeenCalledWith('downloading ', 100, 60)
63+
expect(pgb.print).not.toHaveBeenCalled()
6464
})
6565
})
6666

@@ -74,10 +74,10 @@ describe('download', () => {
7474
return Promise.resolve()
7575
.then(command)
7676
.then(() => {
77-
expect(Progress.mock.instances[0].update).toBeCalledWith(100, '100 B / 100 B')
78-
expect(Progress.mock.instances[0].stop).toBeCalledWith()
79-
expect(pgb.api.downloadApp).toBeCalledWith('12', 'ios', '.')
80-
expect(Progress).toBeCalledWith('downloading ', 100, 40)
77+
expect(Progress.mock.instances[0].update).toHaveBeenCalledWith(100, '100 B / 100 B')
78+
expect(Progress.mock.instances[0].stop).toHaveBeenCalledWith()
79+
expect(pgb.api.downloadApp).toHaveBeenCalledWith('12', 'ios', '.')
80+
expect(Progress).toHaveBeenCalledWith('downloading ', 100, 40)
8181
})
8282
})
8383

@@ -90,7 +90,7 @@ describe('download', () => {
9090
.then(command)
9191
.then(done.fail)
9292
.catch(() => {
93-
expect(Progress).not.toBeCalledWith()
93+
expect(Progress).not.toHaveBeenCalledWith()
9494
done()
9595
})
9696
})
@@ -107,6 +107,6 @@ describe('download', () => {
107107
test('should support completion', () =>
108108
Promise.resolve()
109109
.then(command.completion)
110-
.then(() => expect(complete.appAndPlatform).toBeCalled())
110+
.then(() => expect(complete.appAndPlatform).toHaveBeenCalled())
111111
)
112112
})

test/commands/helpers/bind-progress.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,47 @@ describe('bind-progress', () => {
3434

3535
test('should debug files on zip/files event', () => {
3636
process.emit('zip/files', { foo: 'bar' })
37-
expect(pgb.debug).toBeCalledWith({ foo: 'bar' })
37+
expect(pgb.debug).toHaveBeenCalledWith({ foo: 'bar' })
3838
})
3939

4040
test('should stop progress on end events', () => {
4141
process.emit('api/write', { size: 2000000, pos: 25 })
4242
process.emit('zip/write', { size: 2000000, pos: 25 })
4343
process.emit('api/connect')
4444
process.emit('zip/end')
45-
expect(Progress.mock.instances[0].stop).toBeCalledWith()
46-
expect(Progress.mock.instances[1].stop).toBeCalledWith()
45+
expect(Progress.mock.instances[0].stop).toHaveBeenCalledWith()
46+
expect(Progress.mock.instances[1].stop).toHaveBeenCalledWith()
4747
})
4848

4949
test('should instantiate and/or update progress on api/write', () => {
5050
process.emit('api/write', { size: 2000000, pos: 25 })
5151
process.emit('api/write', { size: 2000000, pos: 25 })
52-
expect(Progress).toBeCalledWith('uploading ', 2000000, 40)
53-
expect(Progress.mock.instances[0].update).toBeCalledWith(25, '25 B / 1.9 MB')
52+
expect(Progress).toHaveBeenCalledWith('uploading ', 2000000, 40)
53+
expect(Progress.mock.instances[0].update).toHaveBeenCalledWith(25, '25 B / 1.9 MB')
5454
})
5555

5656
test('should not instantiate and/or update progress on api/write if too small', () => {
5757
process.emit('api/write', { size: 100, pos: 25 })
58-
expect(Progress).not.toBeCalledWith()
58+
expect(Progress).not.toHaveBeenCalledWith()
5959
})
6060

6161
test('should instantiate and/or update progress on api/write if too small but has zipper', () => {
6262
process.emit('zip/write', { size: 2000000, pos: 25 })
63-
expect(Progress.mock.instances[0].update).toBeCalledWith(25, '25 B / 1.9 MB')
63+
expect(Progress.mock.instances[0].update).toHaveBeenCalledWith(25, '25 B / 1.9 MB')
6464
process.emit('api/write', { size: 100, pos: 22 })
65-
expect(Progress.mock.instances[1].update).toBeCalledWith(22, '22 B / 100 B')
65+
expect(Progress.mock.instances[1].update).toHaveBeenCalledWith(22, '22 B / 100 B')
6666
})
6767

6868
test('should not instantiate and/or update progress on api/write if noprogress', () => {
6969
pgb.opts.noprogress = true
7070
process.emit('api/write', { size: 2000000, pos: 25 })
71-
expect(Progress).not.toBeCalledWith()
71+
expect(Progress).not.toHaveBeenCalledWith()
7272
})
7373

7474
test('should instantiate and/or update progress on zip/write', () => {
7575
process.emit('zip/write', { size: 200000, pos: 25 })
7676
process.emit('zip/write', { size: 200000, pos: 25 })
77-
expect(Progress).toBeCalledWith('archiving ', 200000, 40)
77+
expect(Progress).toHaveBeenCalledWith('archiving ', 200000, 40)
7878
})
7979

8080
test('should not bind events if noprogress', () => {
@@ -84,6 +84,6 @@ describe('bind-progress', () => {
8484
bindProgress = BindProgress()
8585
process.emit('zip/write', { size: 2000000, pos: 25 })
8686
expect(process.eventNames()).not.toContain(['zip/files', 'zip/end', 'api/connect', 'zip/write', 'api/write'])
87-
expect(Progress).not.toBeCalled()
87+
expect(Progress).not.toHaveBeenCalled()
8888
})
8989
})

test/commands/helpers/complete.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('complete', () => {
1515
.then(complete.app)
1616
.then((result) => {
1717
expect(result).toEqual([12, 13])
18-
expect(pgb.api.getApps).toBeCalledWith()
18+
expect(pgb.api.getApps).toHaveBeenCalledWith()
1919
})
2020
})
2121

@@ -36,7 +36,7 @@ describe('complete', () => {
3636
.then(complete.appAndPlatform)
3737
.then((result) => {
3838
expect(result).toEqual([12, 13])
39-
expect(pgb.api.getApps).toBeCalledWith()
39+
expect(pgb.api.getApps).toHaveBeenCalledWith()
4040
})
4141
})
4242

@@ -67,7 +67,7 @@ describe('complete', () => {
6767
.then(complete.key)
6868
.then((result) => {
6969
expect(result).toEqual([12, 13])
70-
expect(pgb.api.getKeys).toBeCalledWith('ios')
70+
expect(pgb.api.getKeys).toHaveBeenCalledWith('ios')
7171
})
7272
})
7373

test/commands/helpers/validators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('validators', () => {
4747
jest.mock('../../../src/commands/usage')
4848
expect(pgb.opts.short_usage).toBeFalsy()
4949
expect(() => validators.args(1)).toThrow('')
50-
expect(pgb.error).lastCalledWith('command requires 1 argument(s)')
50+
expect(pgb.error).toHaveBeenLastCalledWith('command requires 1 argument(s)')
5151
expect(pgb.opts.short_usage).toBeTruthy()
5252
pgb.opts = { commands: ['cmd', 'arg1'] }
5353
expect(() => validators.args(1)).not.toThrow()

0 commit comments

Comments
 (0)