Skip to content

Commit

Permalink
Dep version bump and minor change in flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Himavanth committed Mar 6, 2020
1 parent 4b56d80 commit e9098e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 52 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@adobe/aio-app-scripts": "^0.11.0",
"@adobe/aio-lib-core-config": ">=1.2.8",
"@adobe/generator-aio-app": "^0.5.4",
"@adobe/generator-aio-app": "^0.5.5",
"@oclif/command": "^1.5.11",
"@oclif/config": "^1.12.9",
"chalk": "^3.0.0",
Expand Down
14 changes: 1 addition & 13 deletions src/commands/app/add/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ governing permissions and limitations under the License.
const BaseCommand = require('../../../BaseCommand')
const yeoman = require('yeoman-environment')
const debug = require('debug')('aio-cli-plugin-app:init')
const { flags } = require('@oclif/command')

class AddCICommand extends BaseCommand {
async run () {
Expand All @@ -23,9 +22,7 @@ class AddCICommand extends BaseCommand {
const generator = '@adobe/generator-aio-app/generators/add-ci'
const env = yeoman.createEnv()
env.register(require.resolve(generator), 'gen')
const res = await env.run('gen', {
'skip-prompt': flags.yes
})
const res = await env.run('gen')
return res
}
}
Expand All @@ -34,15 +31,6 @@ AddCICommand.description = `Add CI files
`

AddCICommand.flags = {
yes: flags.boolean({
description: 'Skip questions, and use all default values',
default: false,
char: 'y'
}),
'skip-install': flags.boolean({
description: 'Skip npm installation after files are created',
default: false
}),
...BaseCommand.flags
}

Expand Down
41 changes: 3 additions & 38 deletions test/commands/app/add/ci.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,48 +54,13 @@ describe('template module cannot be registered', () => {
})
})

describe('good flags', () => {
test('--yes', async () => {
await TheCommand.run(['--yes'])

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

test('--yes --skip-install', async () => {
await TheCommand.run(['--yes', '--skip-install'])

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

test('--skip-install', async () => {
await TheCommand.run(['--skip-install'])

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

test('no flags', async () => {
describe('no flags', () => {
test('should pass', async () => {
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
})
expect(mockRun).toHaveBeenCalledWith(genName)
})
})

0 comments on commit e9098e8

Please sign in to comment.