Skip to content

Commit

Permalink
Update and running CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreKavalerski committed Dec 28, 2017
1 parent a1694df commit 3adbced
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions bin/main.js
Original file line number Diff line number Diff line change
@@ -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);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ const pkg = require('../package.json');

program
.version(pkg.version)
.description(pkg.description)
.parse(process.argv);
11 changes: 9 additions & 2 deletions tests/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});

0 comments on commit 3adbced

Please sign in to comment.