diff --git a/bin/lissie.js b/bin/lissie.js deleted file mode 100755 index f064762..0000000 --- a/bin/lissie.js +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env node - -require('../src/cli') diff --git a/package.json b/package.json index ba7f8eb..d6681fc 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -31,7 +31,6 @@ "instrument": false }, "files": [ - "bin", "dist", "licenses" ], diff --git a/src/cli.js b/src/cli.js old mode 100644 new mode 100755 index 2aad5a6..9dbd6c2 --- a/src/cli.js +++ b/src/cli.js @@ -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 + + 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)) diff --git a/src/cli.test.js b/src/cli.test.js index 77aa329..d9a7179 100644 --- a/src/cli.test.js +++ b/src/cli.test.js @@ -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') })