Skip to content

Commit

Permalink
Fix #109
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Jul 6, 2016
1 parent 96e8b40 commit 1d1582a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.5.2

* Fix option alias issue [#109](https://github.com/typicode/hotel/issues/109)

## 0.5.1

* Fix conf issue
Expand Down
38 changes: 18 additions & 20 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,24 @@ module.exports = (processArgv) => {
.command(
'add <cmd|url> [options]',
'Add server or proxy',
(yargs) => {
yargs
.option('name', {
alias: 'n',
describe: 'Name'
})
.option('out', {
alias: 'o',
describe: 'Output'
})
.option('env', {
alias: 'e',
describe: 'Env'
})
.option('port', {
alias: 'p',
describe: 'Port'
})
.demand(1)
},
(yargs) => yargs
.option('name', {
alias: 'n',
describe: 'Name'
})
.option('out', {
alias: 'o',
describe: 'Output'
})
.option('env', {
alias: 'e',
describe: 'Env'
})
.option('port', {
alias: 'p',
describe: 'Port'
})
.demand(1),
(argv) => servers.add(argv['cmd|url'], argv)
)
.command(
Expand Down
16 changes: 15 additions & 1 deletion test/cli/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ test('add should support options', (t) => {
const e = 'FOO'
const p = 3000

// servers.add('node index.js', opts)
cli([
'', '',
'add', cmd,
Expand Down Expand Up @@ -100,6 +99,21 @@ test('add should support options', (t) => {
)
})

test('add should support option aliases', (t) => {
process.env.FOO = 'FOO'
const cmd = 'node index.js'
const n = 'alias-test'

cli([
'', '',
'add', cmd,
'--name', n
])

const file = path.join(serversDir, 'alias-test.json')
t.true(fs.existsSync(file))
})

test('add should support url', (t) => {
cli([
'', '',
Expand Down

0 comments on commit 1d1582a

Please sign in to comment.