Skip to content

Commit

Permalink
make cli credentials optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ovhemert committed Dec 10, 2019
1 parent 558cd0a commit 2ed144f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function main () {
.option('-p, --project <project>', 'Your Google Cloud Platform project ID')
.action(({ credentials, project }) => {
try {
if (!process.env.GOOGLE_APPLICATION_CREDENTIALS && !credentials) { throw Error('Credentials are missing.') }
const _credentials = credentials || process.env.GOOGLE_APPLICATION_CREDENTIALS
if (!process.env.PROJECT_ID && !project) { throw Error('Project is missing.') }
const _project = project || process.env.PROJECT_ID
Expand Down
5 changes: 3 additions & 2 deletions test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ test('displays version info', (t) => {
})
})

test('throws on missing credentials', (t) => {
test('works without passing credentials', t => {
t.plan(1)
delete process.env.GOOGLE_APPLICATION_CREDENTIALS
const app = spawn('node', [appPath, '-p', 'project-id'])
app.stdout.on('data', (data) => {
const msg = data.toString()
const res = (msg.indexOf('Credentials are missing') >= 0)
const res = (msg.indexOf('logging') >= 0)
t.ok(res)
app.kill()
})
})

Expand Down

0 comments on commit 2ed144f

Please sign in to comment.