获取 npm-lifecycle 版本

@returns {string} npm-lifecycle version
519072
function getNpmLifecycleVersion () {
  const npmPath = which.sync('npm', {
    nothrow: true
  })

  if (!npmPath) {
    return ''
  }

  const pathSuffix = process.platform === 'win32'
    ? '../node_modules/npm/node_modules/npm-lifecycle/package.json'
    : '../../node_modules/npm-lifecycle/package.json'

  const lifecyclePkgPath = path.join(fs.realpathSync(npmPath), pathSuffix)

  if (!fs.existsSync(lifecyclePkgPath)) {
    return ''
  }

  // eslint-disable-next-line global-require
  return require(lifecyclePkgPath).version
}
727499
async function _expectPackageVersion(args) {
  const packageVersion = require(
    path.resolve(__dirname, '../../package.json')
  ).version;
  await _expectSuccessMessage(args, `${packageVersion}\n`);
}
85599
async function checkNewVersion() {
    try {
        const file = path.join(constants.GLOBAL_DIR, constants.GLOBAL_INFO);

        // If it does not exist, create it.
        if (!fs.existsSync(file)) {
            createFile({
                name: file,
                source: `{"lastCheckForUpdate": 0}\n`,
            });
        }

        // Read info file
        const json = fs.readJsonSync(file, 'utf8');
        const lastCheckForUpdate = json.lastCheckForUpdate;

        // Show update message
        if (lastCheckForUpdate + (6 * 3600 * 1000) < Date.now()) {
            const latestVersion = await request(`${constants.FIREBASE_DATABASE_URL}/version/cli/latest.json`);
            if (latestVersion && latestVersion !== 'null' && latestVersion !== `"${pjson.version}"`) {
                const scale = pjson.version.length + latestVersion.length - 10;

                console.log();
                console.log(`${`   ┏`.yellow}${`─`.repeat(scale + 45).yellow}${`┓`.yellow}`);
                console.log(`${`   │`.yellow}${` `.repeat(scale + 45)}${`│`.yellow}`);
                console.log(`${`   │`.yellow}${`      Update available ${pjson.version} -> `}${`${latestVersion}`.green}${`        │`.yellow}`);
                console.log(`${`   │`.yellow}${`  Run `}${`npm i -g google-apps-script`.red}${` to update`}${` `.repeat(scale + 2)}${`│`.yellow}`);
                console.log(`${`   │`.yellow}${` `.repeat(scale + 45)}${`│`.yellow}`);
                console.log(`${`   ┗`.yellow}${`─`.repeat(scale + 45).yellow}${`┛`.yellow}`);
                console.log();
            }

            // Update lastCheckForUpdate
            json.lastCheckForUpdate = Date.now();
            createFile({
                name: file,
                source: JSON.stringify(json),
            });
            return true;
        }
        return false;
    } catch (err) {
        err.origin = 'checkNewVersion';
        await error.log(err);
        return false;
    }
}
329563
function getPlatVersionsFromFileSystem(projectRoot){
    var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
    var platformVersions = platforms_on_fs.map(function(platform){
        var script = path.join(projectRoot, 'platforms', platform, 'cordova', 'version');
        return Q.ninvoke(child_process, 'exec', script, {}).then(function(result){
            var version = result[0];

            // clean the version we get back from the script
            // This is necessary because the version script uses console.log to pass back
            // the version. Using console.log ends up adding additional line breaks/newlines to the value returned.
            // ToDO: version scripts should be refactored to not use console.log()
            var versionCleaned = version.replace(/\r?\n|\r/g, '');
            return {platform: platform, version: versionCleaned};
        });
    });

    return Q.all(platformVersions);
}
54384
def version
      response = get('/getVersion', {}, false)
      ApiVersion.new(response.body['version'], response.body['builddate'])
    end
369090
function getVersion() {
        if (_baseVersion[2] > 8) {
            _baseVersion[2] = 0;
            _baseVersion[1]++;
            if (_baseVersion[1] > 8) {
                _baseVersion[1] = 0;
                _baseVersion[0]++;
            }
        } else {
            _baseVersion[2]++;
        }
        return _baseVersion.join('.');
    }
183869
public function getVersion()
  {
    $composerJson = config('app.dir') . 'composer.json';

    if (file_exists($composerJson)) {
      $composer = json_decode(file_get_contents($composerJson, true));

      $version  = isset($composer->version) ? $composer->version : '1';
      $require  = isset($composer->require) ? (array)$composer->require : false;

      if (!is_array($require)) return "{$version} (1)";

      if (isset($require['modulusphp/framework'])) {
        return $version . " ({$require['modulusphp/framework']})";
      } else {
        return "{$version} (1)";
      }
    }

    return '1';
  }
394160
public String getVersion() {
        final Object version = getHeader(HttpMessageHeaders.HTTP_VERSION);

        if (version != null) {
            return version.toString();
        }

        return null;
    }
1247399
function getAvailableNpmVersions(module_name) {
    var npm = require('npm');
    return Q.nfcall(npm.load).then(function () {
        return Q.ninvoke(npm.commands, 'view', [module_name, 'versions'], /* silent = */ true).then(function (result) {
            // result is an object in the form:
            //     {'<version>': {versions: ['1.2.3', '1.2.4', ...]}}
            // (where <version> is the latest version)
            return result[Object.keys(result)[0]].versions;
        });
    });
}
246122
function version(options) {
  let opts = options || {
    typeKey: '_type',
  };
  if (typeof options === 'string') {
    opts = {
      typeKey: options,
    };
  }
  const typeKey = opts.typeKey;
  const override = opts.override;

  return (ctx, next) => {
    const query = ctx.query;
    const currentPath = ctx.path;
    const reg = /^\/v\d+/i;
    const result = reg.exec(currentPath);
    const acceptConfig = {};
    if (result) {
      const versionDesc = result[0];
      const v = parseInt(versionDesc.substring(2), 10);
      /* eslint no-param-reassign:0 */
      ctx.path = ctx.path.substring(versionDesc.length);
      if (override) {
        ctx.originalPath = ctx.path;
      }
      acceptConfig.version = v;
    }
    if (query[typeKey]) {
      acceptConfig.type = query[typeKey];
      delete query[typeKey];
      /* eslint no-param-reassign:0 */
      ctx.query = query;
    }
    const acceptReg = /^application\/vnd\.\S+\.v(\d)+(\+(\S+))?/i;
    const acceptResult = acceptReg.exec(ctx.get('Accept'));
    /* istanbul ignore else */
    if (acceptResult) {
      acceptConfig.version = parseInt(acceptResult[1], 10);
      /* istanbul ignore else */
      if (acceptResult[3]) {
        acceptConfig.type = acceptResult[3];
      }
    }
    /* istanbul ignore else */
    if (acceptConfig.version) {
      /* eslint no-param-reassign:0 */
      ctx.state.acceptConfig = acceptConfig;
      ctx.versionConfig = acceptConfig;
    }
    return next();
  };
}
876047
function getBrowserVersion(version) {
  if (!version) {
    return {
      major: '',
      minor: '',
    };
  }
  var parts = version.split('.');
  return {
    major: parts[0],
    minor: parts[1],
  };
}
1058690
async function getVersions () {
  let versions = process.versions
  let prettyVersions = []
  versions.os = process.platform + ' ' + process.arch

  for (let variable in versions) {
    if (versions.hasOwnProperty(variable)) {
      prettyVersions.push(`${variable}: ${versions[variable]}`)
    }
  }

  try {
    const windowsVersion = await _getWindowsVersion()
    prettyVersions.push(windowsVersion.replace(/  +/g, ' '))
  } catch (error) {
    // Do nothing, we're okay with this failing.
    // Most common reason is we're not on an english
    // Windows.
  }

  return prettyVersions.join(' | ')
}
215154
function (version) {
    var vs = version.replace(/[^0-9\\.]/g, '');
    vs = vs.replace(/\./g, '_');
    return vs;
  }
135390
private String getProjectVersion() {
        return Utils.convertToDebianVersion(getProject().getVersion(), this.snapshotExpand, this.snapshotEnv, this.snapshotTemplate, session.getStartTime());
    }
455671
function parseVersion(v) {
  const [
    , // Full match of no interest.
    major = null,
    sub = null,
    minor = null,
  ] = /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-.*)?$/.exec(v);
  if (major === null || sub === null || minor === null) {
    const err = new Error(`Invalid version string (${v})!`);
    logger.error(err);
    throw err;
  }

  return {
    major,
    sub,
    minor,
  };
}
1000992
def get_version():
    
    _globals = {}
    _locals = {}
    exec(
        compile(
            open(TOP + "/manta/version.py").read(), TOP + "/manta/version.py",
            'exec'), _globals, _locals)
    return _locals["__version__"]
594578
function getNewVersion () {
    header();
    const options = getVersionOptions(oldVersion);
    let key, version;
    log(`The current version is ${oldVersion.cyan}.`);
    log('');
    log('What should the next version be?');
    for (key in options) { log((+key + 1) + ') ' + options[ key ].cyan); }
    log('');
    write('Please select a new version: ');
    const type = prompt();

    if (options[ type - 1 ]) version = options[ type - 1 ];
    else if (type.match(/^\d+\.\d+\.\d+(-rc\.?\d+)?$/)) version = type;
    else throw new Error('Your entry was invalid.');

    log('');
    log('The new version will be ' + version.cyan + '.');
    write(`Is this correct? ${"[yes/no]".cyan} `);
    return prompt() === 'yes' ? version : getNewVersion();

    function getVersionOptions (version) {
      return version.match(/-rc\.?\d+$/)
          ? [increment(version, 'rc'), increment(version, 'minor')]
          : [increment(version, 'patch'), addRC(increment(version, 'minor'))];

      function increment (versionString, type) {
        const version = parseVersion(versionString);
        if (version.rc) {
          switch (type) {
            case 'minor': version.rc = 0; break;
            case 'rc': version.rc++; break;
          }
        } else {
          version[ type ]++;
          // reset any version numbers lower than the one changed
          switch (type) {
            case 'minor': version.patch = 0;
            case 'patch': version.rc = 0;
          }
        }
        return getVersionString(version);

        function parseVersion (version) {
          const parts = version.split(/-rc\.|\./g);
          return {
            string: version,
            major:  parts[ 0 ],
            minor:  parts[ 1 ],
            patch:  parts[ 2 ],
            rc:     parts[ 3 ] || 0
          };
        }

        function getVersionString (version) {
          let str = version.major + '.' + version.minor + '.' + version.patch;
          if (version.rc) str += '-rc.' + version.rc;
          return str;
        }
      }

      function addRC (str) {
        return str + '-rc.1';
      }
    }
  }