Skip to content

Commit

Permalink
Get package version number dynamically based on package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
SpencerCDixon committed Feb 11, 2016
1 parent 6116c2c commit 32cb53d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/
3 changes: 2 additions & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import commander from 'commander';
import { version } from '../version';

const program = commander
.version('0.0.1')
.version(version())
.command('init', 'initialize a .reduxrc file for project details')
.parse(process.argv);
1 change: 0 additions & 1 deletion src/textHelpers.js

This file was deleted.

8 changes: 8 additions & 0 deletions src/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import path from 'path';
import fs from 'fs';

export const version = () => {
const pkgPath = path.join(path.dirname(module.id), '../package.json');
const pkgJSON = JSON.parse(fs.readFileSync(pkgPath));
return pkgJSON.version;
}

0 comments on commit 32cb53d

Please sign in to comment.