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

Commit

Permalink
fix for #2
Browse files Browse the repository at this point in the history
  • Loading branch information
goya committed May 11, 2018
1 parent e1aed92 commit 72a337c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/commands/helpers/wait.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pgb-cli",
"version": "1.0.1",
"version": "1.0.2",
"description": "nodeJS CLI to PhoneGap Build",
"keywords": [
"PhoneGap",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/helpers/wait.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = (app) => {
clearInterval(pollInt)
clearInterval(printInt)

if (app.error !== {} && pgb.opts.exitcode) {
if (Object.keys(app.error).length > 0 && pgb.opts.exitcode) {
reject(new Error())
} else if (app.package) {
resolve(app)
Expand Down
19 changes: 15 additions & 4 deletions test/commands/helpers/wait.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ describe('progress', () => {
})

test('should resolve with app if already completed', () => {
return wait({id: 12, package: 'com.example', status: {}, completed: true})
return wait({id: 12, package: 'com.example', status: {}, error: {}, completed: true})
.then((app) => {
expect(app).toEqual({id: 12, package: 'com.example', status: {}, completed: true})
expect(app).toEqual({id: 12, package: 'com.example', status: {}, error: {}, completed: true})
expect(pgb.api.getApp).not.toBeCalled()
expect(pgb.api.getStatus).not.toBeCalled()
})
})

test('should resolve with app if exit', () => {
pgb.opts.exit = true
return wait({id: 12, package: 'com.example', status: {}, completed: true})
return wait({id: 12, package: 'com.example', status: {}, error: {}, completed: true})
.then((app) => {
expect(app).toEqual({id: 12, package: 'com.example', status: {}, completed: true})
expect(app).toEqual({id: 12, package: 'com.example', status: {}, error: {}, completed: true})
expect(pgb.api.getApp).not.toBeCalled()
expect(pgb.api.getStatus).not.toBeCalled()
})
Expand All @@ -50,6 +50,17 @@ describe('progress', () => {
})
})

test('should not reject if exitcode and a successful build', (done) => {
pgb.opts.exitcode = true
return wait({id: 12, package: 'com.example', status: {}, error: { }, completed: true})
.then((app) => {
expect(app).toEqual({id: 12, package: 'com.example', status: {}, error: { }, completed: true})
expect(pgb.api.getApp).not.toBeCalled()
expect(pgb.api.getStatus).not.toBeCalled()
expect(stdout.flush().stderr).toHaveLength(1)
})
})

test('should not reject if not exitcode and a failed build', () => {
pgb.opts.exitcode = false
return wait({id: 12, package: 'com.example', status: {}, error: { android: 'bad' }, completed: true})
Expand Down

0 comments on commit 72a337c

Please sign in to comment.