Skip to content

Commit

Permalink
feat: implement command-line script
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Aug 29, 2017
1 parent 957da98 commit 8b6a150
Show file tree
Hide file tree
Showing 7 changed files with 3,425 additions and 105 deletions.
3 changes: 3 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../src/cli')()
21 changes: 21 additions & 0 deletions bin/cli.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import test from 'ava'
import { promisify } from 'util'
import childProcess from 'child_process'
import path from 'path'

const execFile = promisify(childProcess.execFile)
const tested = path.join(__dirname, 'cli.js')

test('output help without command', async (t) => {
const { code, stdout, stderr } = await t.throws(execFile(tested))
t.true(code === 1)
t.true(stdout === '')
t.true(stderr.startsWith('ybiquitous <command>'))
t.true(stderr.includes('init Initialize Node.js project'))
})

test('output help with `--help` option', async (t) => {
const { stdout, stderr } = await execFile(tested, ['--help'])
t.true(stdout.startsWith('ybiquitous <command>'))
t.true(stderr === '')
})

0 comments on commit 8b6a150

Please sign in to comment.