Skip to content

Commit

Permalink
test improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
sadorlovsky committed Dec 15, 2016
1 parent f6287b3 commit b16704a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
3 changes: 0 additions & 3 deletions bin/lissie.js

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "CLI tool for generate LICENSE",
"main": "dist/lissie.js",
"bin": {
"license": "bin/lissie.js"
"license": "dist/cli.js"
},
"preferGlobal": true,
"scripts": {
Expand All @@ -31,7 +31,6 @@
"instrument": false
},
"files": [
"bin",
"dist",
"licenses"
],
Expand Down
26 changes: 23 additions & 3 deletions src/cli.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
#!/usr/bin/env node

const meow = require('meow')
const chalk = require('chalk')
const lissie = require('./lissie')

const cli = meow(`
Usage
$ lissie <license>
`)
$ license <license>
Options
--author, -a
--year, -y
Examples
$ license
$ license mit
$ license mit -a "Zach Orlovsky"
`, {
alias: {
a: 'author',
y: 'year'
}
})

const highlight = text => text.replace(
/\{year\}|\{author\}|\{project\}|\{email\}/gi,
matched => chalk.black.bgYellow(matched)
)

lissie(cli.input[0] || 'mit')
lissie({
license: cli.input[0] || 'mit',
author: cli.flags.author,
year: cli.flags.year
})
.then(highlight)
.then(text => console.log(text))
.catch(({ message }) => console.log(message))
6 changes: 3 additions & 3 deletions src/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import execa from 'execa'
import lissie from './lissie'

test('MIT without params', async t => {
const { stdout } = await execa('bin/lissie.js')
const { stdout } = await execa('src/cli.js')
t.is(stdout, await lissie('mit'))
})

test('MIT', async t => {
const { stdout } = await execa('bin/lissie.js', ['mit'])
const { stdout } = await execa('src/cli.js', ['mit'])
t.is(stdout, await lissie('mit'))
})

test('Error message if license not exists', async t => {
const { stdout } = await execa('bin/lissie.js', ['no-exist'])
const { stdout } = await execa('src/cli.js', ['no-exist'])
t.is(stdout, 'There is not that license')
})

0 comments on commit b16704a

Please sign in to comment.