UNPKG

patriot

Version:

Patriot command-line interface and node.js library.

61 lines (51 loc) 1.15 kB
/*! * Module dependencies. */ var Command = require('./util/command'), path = require('path'), util = require('util'), fs = require('fs'); /*! * Command setup. */ module.exports = { create: function(patriot) { return new VersionCommand(patriot); } }; function VersionCommand(patriot) { return Command.apply(this, arguments); } util.inherits(VersionCommand, Command); /** * Version reporter. * * Report the version of npm package, npm module, or Patriot. * * Example: * * => 2.8.0-0.10.6 * * { * npm: '2.8.0-0.10.6', * module: '0.10.6', * patriot: '2.8.0' * } * * Returns: * * {Object} that contains the versions. */ VersionCommand.prototype.run = function(options, callback) { // load package.json var packagePath = path.join(__dirname, '..', '..', 'package.json'), packageJSON = JSON.parse(fs.readFileSync(packagePath), 'utf8'); // get version var version = packageJSON.version; // parse version types return { npm: version, patriot: version.split('-')[0], module: version.split('-')[1] }; };