diff --git a/bin/main.js b/bin/main.js new file mode 100644 index 0000000..99a4514 --- /dev/null +++ b/bin/main.js @@ -0,0 +1,7 @@ +#!/usr/bin/env node +'use strict'; + +var program = require('commander'); +var pkg = require('../package.json'); + +program.version(pkg.version).description(pkg.description).parse(process.argv); \ No newline at end of file diff --git a/package.json b/package.json index af866cc..9d3f2a8 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "clear": "rimraf bin", - "build": "npm run clear && ./node_modules/.bin/babel --out-dir bin src", + "create:lib":"./node_modules/.bin/babel --out-dir bin src", + "build": "npm run clear && npm run create:lib", "build:watch": "npm run build -- --watch", "lint": "./node_modules/.bin/eslint src/*.js", "prepush": "npm run lint && npm run test", diff --git a/src/main.js b/src/main.js index 36cb2b1..16ea12c 100644 --- a/src/main.js +++ b/src/main.js @@ -5,4 +5,5 @@ const pkg = require('../package.json'); program .version(pkg.version) + .description(pkg.description) .parse(process.argv); diff --git a/tests/main.spec.js b/tests/main.spec.js index c651489..86cbbf7 100644 --- a/tests/main.spec.js +++ b/tests/main.spec.js @@ -4,11 +4,18 @@ const pkg = require('../package.json'); const btcConverter = 'node.exe ./src/main.js'; describe('Main CLI', () => { - it('should return version of btc-conv', (done) => { + it('should return version when btc-conv --version', (done) => { exec(`${btcConverter} --version`, (err, stdout, stderr) => { if (err) throw err; expect(stdout.replace('\n', '')).to.be.equal(pkg.version); done(); - }) + }); + }); + it('should return the description when btc-conv --help', (done) => { + exec(`${btcConverter} --help`, (err, stdout, stderr) => { + if (err) throw err; + expect(stdout.includes('A CLI to convert Bitcoin to any currency')).to.be.true; + done(); + }); }); });