Skip to content

Commit

Permalink
Using services from imported config if present (#290)
Browse files Browse the repository at this point in the history
* Using services from imported config if present

* lint fix

Co-authored-by: Shazron Abdullah <[email protected]>
  • Loading branch information
Himavanth and shazron authored Sep 22, 2020
1 parent d03035d commit 9d5f824
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/commands/app/add/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AddActionCommand extends BaseCommand {

aioLogger.debug(`adding component ${args.component} to the project, using flags: ${flags}`)

const services = (config.get('services') || []).map(s => s.code).join(',')
const services = (config.get('services') || config.get('project.workspace.details.services') || []).map(s => s.code).join(',')

const generator = '@adobe/generator-aio-app/generators/add-action'
const env = yeoman.createEnv()
Expand Down
21 changes: 21 additions & 0 deletions test/commands/app/add/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,25 @@ describe('good flags', () => {
'adobe-services': 'CampaignSDK,AdobeAnalyticsSDK'
})
})

test('pass services config codes from imported config to generator-aio-app', async () => {
config.get.mockImplementation((key) => {
if (key === 'services') {
return undefined
} else if (key === 'project.workspace.details.services') {
return [{ code: 'CampaignSDK' }, { code: 'AdobeAnalyticsSDK' }]
}
})

await TheCommand.run([])

expect(yeoman.createEnv).toHaveBeenCalled()
expect(mockRegister).toHaveBeenCalledTimes(1)
const genName = mockRegister.mock.calls[0][1]
expect(mockRun).toHaveBeenCalledWith(genName, {
'skip-prompt': false,
'skip-install': false,
'adobe-services': 'CampaignSDK,AdobeAnalyticsSDK'
})
})
})

0 comments on commit 9d5f824

Please sign in to comment.