diff --git a/src/DeployServiceCommand.js b/src/DeployServiceCommand.js index cdba96e4..042f277e 100644 --- a/src/DeployServiceCommand.js +++ b/src/DeployServiceCommand.js @@ -14,7 +14,8 @@ const { Flags } = require('@oclif/core') const { PropertyDefault } = require('./properties') const runtimeLib = require('@adobe/aio-lib-runtime') -const { getToken, context, CLI } = require('@adobe/aio-lib-ims') +const { getToken, context } = require('@adobe/aio-lib-ims') +const { CLI } = require('@adobe/aio-lib-ims/src/context') const { getCliEnv } = require('@adobe/aio-lib-env') const RuntimeBaseCommand = require('./RuntimeBaseCommand') @@ -38,7 +39,7 @@ class DeployServiceCommand extends RuntimeBaseCommand { let contextName = CLI // default const currentContext = await context.getCurrent() // potential override - if (currentContext !== CLI) { + if (currentContext && currentContext !== CLI) { contextName = currentContext } else { await context.setCli({ 'cli.bare-output': true }, false) // set this globally diff --git a/test/DeployServiceCommand.test.js b/test/DeployServiceCommand.test.js index 0189204b..c0f8dd66 100644 --- a/test/DeployServiceCommand.test.js +++ b/test/DeployServiceCommand.test.js @@ -62,8 +62,8 @@ describe('DeployServiceCommand', () => { getCliEnv.mockReturnValue(mockEnv) }) - test('should use CLI context by default', async () => { - context.getCurrent.mockResolvedValue(CLI) + test('should use CLI context (default) if current context undefined', async () => { + context.getCurrent.mockResolvedValue(undefined) getToken.mockResolvedValue(mockToken) const result = await command.getAccessToken()