all files / version/ index.js

62.5% Statements 5/8
100% Branches 0/0
33.33% Functions 1/3
62.5% Lines 5/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47    1×   1×               2×   2×                                                             1×  
'use strict';
 
const appRoot  = require('app-root-path');
 
const settings = require(`${appRoot}/package.json`);
 
/**
 * Class which builds an Object for returning local version information  .
 * @name sqz.tasks.version
 */
class Version {
  constructor(sqz) {
    this.sqz = sqz;
 
    this.versionData = {
      squeezerCliVersion : `v${settings.version}`,
      nodeVersion        : process.version,
      osPlatform         : process.platform
    };
  }
 
  /**
   * Return current version information
   *
   * @returns {Object}
   */
  get() {
    return this.versionData;
  }
 
  /**
   * Return markdown formatted version message
   *
   * @returns {Object}
   */
  msg() {
    const msg =
            `* Squeezer CLI version: ${this.versionData.squeezerCliVersion}\n` +
            `* Node version: ${this.versionData.nodeVersion}\n` +
            `* OS platform: ${this.versionData.osPlatform}`;
 
    return msg;
  }
}
 
module.exports = Version;