lib.js
function getPackageVersion() {
  var packageJson = path.join(process.cwd(), 'package.json'),
    version;
  try {
    version = require(packageJson).version;
  } catch (unused) {
    throw new Error('Could not load package.json, please make sure it exists');
  }
  if (!semver.valid(version)) {
    throw new Error('Invalid version number found in package.json, please make sure it is valid');
  }

  return [ semver.major(version), semver.minor(version), semver.patch(version) ].join('.');
}
function getPackageVersion() {
  var packageJson = path.join(process.cwd(), 'package.json'),
    version;
  try {
    version = require(packageJson).version;
  } catch (unused) {
    throw new Error('Could not load package.json, please make sure it exists');
  }
  if (!semver.valid(version)) {
    throw new Error('Invalid version number found in package.json, please make sure it is valid');
  }

  return [ semver.major(version), semver.minor(version), semver.patch(version) ].join('.');
}
function getPackageVersion ( ) { var packageJson = path . join ( process . cwd ( ) , 'package.json' ) , version ; try { version = require ( packageJson ) . version ; } catch ( unused ) { throw new Error ( 'Could not load package.json, please make sure it exists' ) ; } if ( ! semver . valid ( version ) ) { throw new Error ( 'Invalid version number found in package.json, please make sure it is valid' ) ; } return [ semver . major ( version ) , semver . minor ( version ) , semver . patch ( version ) ] . join ( '.' ) ; }
Get the current version from the package.json
@method getPackageVersion
@return {String} MAJOR.MINOR version
Get the current version from the package . json