Sync function that takes a package.json path and extracts the version from it.
@param  {string} inPath Path to the project's package.json
@return {string}        The extracted version number in the form 'X.Y.Z'
341574
function extractPackageVersion(inPath) {
    if (!inPath) {
        throw new Error('Input path argument is required');
    }

    // Require here so we have the update version.
    const pkg = fs.readFileSync(inPath, 'utf-8');

    // index 0 is line that matched, index 1 is first control group (version number in this case)
    const matches = /"version": "([0-9]+\.[0-9]+\.[0-9]+)"/.exec(pkg);
    const version = matches[1];

    return version;
}
466126
function extract_to_sync(_path, jszip) {

    var extraction_path = _path === null ? "./" : path.normalize(_path);
    if(extraction_path[extraction_path.length - 1] !== path.sep) {
        extraction_path += path.sep;
    }

    // make sure that the extraction path points to a existing directory
    var stats;
    try { stats = fs.statSync(extraction_path); }
    catch (err) { throw new Error(extraction_path + " doesn't exist"); }
    if (!stats.isDirectory())
        throw new Error(extraction_path + " is not a directory");

    // sort out the unzipped file to directories and files
    var dirs = [];
    var files = [];
    for (var name in jszip.files) {

        var entry = jszip.files[name];

        if (entry.dir)
            dirs.push(name);
        else
            files.push(name);
    }

    // sort the directories ascendingy by level
    dirs.sort(function (a, b) {
        function dir_sep_count(dir) { return (dir.match(/\//g) || []).length; }

        return dir_sep_count(a) - dir_sep_count(b);
    });


    // create the directories
    dirs.forEach(function (dir) {
        try {
            var stats = fs.statSync(extraction_path + dir);
            if(!stats.isDirectory()) {
                throw new Error("!dir");
            }
        }
        catch(err) {
            if(err.code === "ENOENT" || err.message === "!dir") {
                fs.mkdirSync(extraction_path + dir);
            }
            else {
                throw err;
            }
        }
    });

    // write the files
    files.forEach(function (file) {

        var data = jszip.file(file).asNodeBuffer();

        fs.writeFileSync(extraction_path + file, data);
    });

}
1271653
function writePackageVersion(newVersion) {
  var packageJson = path.join(process.cwd(), 'package.json'),
    raw = require(packageJson);

  raw.version = newVersion;

  fs.writeFileSync(packageJson, JSON.stringify(raw, null, 2));
}
137118
def extract_version(filepath='jeni.py', name='__version__'):
    
    context = {}
    for line in open(filepath):
        if name in line:
            exec(line, context)
            break
    else:
        raise RuntimeError('{} not found in {}'.format(name, filepath))
    return context[name]
498714
def get_version(path=VERSION_PATH):
    
    namespace = {}
    exec(read(path), namespace)
    return namespace['get_version'](short=True)
313961
def get_package_version():
    """"""
    base = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(base, "firepit/__init__.py")) as pkg:
        for line in pkg:
            m = version.match(line.strip())
            if not m:
                continue
            return ".".join(m.groups()[0].split(", "))
766923
function discoverVersion() {
    // try to understand package name and current version
    // from package.json or bower.json
    let packageFile;
    let packageFileExtension;
    let packageType;
    let results = {
        name: '',
        currentVersion: ''
    };
    let possiblePackageFiles = ['package.json', 'bower.json', 'package.js'];

    for (possiblePackageFile of possiblePackageFiles) {
        if (fs.existsSync(possiblePackageFile)) {
            packageFile = possiblePackageFile;
            break;
        }
    }

    packageFileExtension = packageFile.substr(packageFile.lastIndexOf('.') + 1);

    if (packageFile) {
        let packageData;

        if (packageFileExtension === 'json') {
            packageData = jsonReader(packageFile);
        }
        if (packageFileExtension === 'js') {
            let tmpData = fs.readFileSync(packageFile).toString().split('\n');
            let nameFound = false;
            let versionFound = false;

            packageData = {};

            for (line of tmpData) {
                if (line.indexOf('name:') >= 0) {
                    nameFound = true;
                    packageData.name = line.split(' ').pop().replace(/'/g, '').replace(/,/g, '');
                }
                if (line.indexOf('version:') >= 0) {
                    versionFound = true;
                    packageData.version = line.split(' ').pop().replace(/'/g, '').replace(/,/g, '');
                }

                if (nameFound && versionFound) {
                    break;
                }
            }
        }

        debugLog('Reading packageFile for init:');
        debugLog('Discovered pacakge name: ' + packageData.name + ' - discovered package version ' + packageData.version);

        if (packageData.name) {
            results.name = packageData.name;
        }
        else {
            print('Can\'t discover package name automatically', 'msgWarning', 'spaced22');
        }

        if (packageData.version) {
            results.currentVersion = packageData.version;
        }
        else {
            print('Can\'t discover package\'s currentVersion automatically', 'msgWarning', 'spaced22');
        }
    }
    else {
        print('Can\'t discover package name and/or currentVersion automatically', 'msgWarning', 'spaced22');
        print('Please fill .versionFilesList.json with the missing informations', 'msgWarning', 'spaced22');
    }

    return results;
}
584113
def get_version(*file_paths):
    """"""
    filename = os.path.join(os.path.dirname(__file__), *file_paths)
    print("Looking for version in: {}".format(filename))
    version_file = open(filename).read()
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError('Unable to find version string.')
1331362
async function markVersions () {
  const packages = JSON.parse(
    (await execa(require.resolve('lerna/cli'), ['list', '--json'])).stdout
  ).filter(p => !p.private)
  const markerPath = path.resolve(__dirname, '../packages/vue-cli-version-marker/package.json')
  const marker = JSON.parse(fs.readFileSync(markerPath))

  const curVersion = marker.version
  const mainVersion = require('../lerna.json').version

  if (semver.prerelease(mainVersion)) {
    marker.version = mainVersion
  } else {
    const releaseType = semver.diff(curVersion, mainVersion) || 'patch'
    marker.version = semver.inc(marker.version, releaseType)
  }

  marker.devDependencies = packages.reduce((prev, pkg) => {
    prev[pkg.name] = pkg.version
    return prev
  }, {})
  fs.writeFileSync(markerPath, JSON.stringify(marker, null, 2))
}
1341584
def get_version(package, url_pattern=URL_PATTERN):
    """"""
    req = requests.get(url_pattern.format(package=package))
    version = parse('0')
    if req.status_code == requests.codes.ok:
        # j = json.loads(req.text.encode(req.encoding))
        j = req.json()
        releases = j.get('releases', [])
        for release in releases:
            ver = parse(release)
            if not ver.is_prerelease:
                version = max(version, ver)
    return version
1146672
function packageNameFromPath(path) {
  var matches = moduleRegex.exec(path);
  return matches && matches.length > 1 ? matches[1] : null;
}
516839
async function updateVersion(file) {
  const { default: config } = await import(`${CONFIGS_PATH}/${file}`);
  const { packageName } = config;

  const packageInfoFile = `${PACKAGES_PATH}/${packageName}/package.json`;
  const { default: packageInfo } = await import(packageInfoFile);

  if (info.version !== packageInfo.version) {
    const newPackageInfo = {
      ...packageInfo,
      version: info.version,
    };

    writeFileAsync(packageInfoFile, JSON.stringify(newPackageInfo, null, '  '))
      .then(
        () => console.log(`Updated ${packageName} to ${info.version}`),
        error => console.log(error),
      );
  }
}
354259
function parseVersion(versionString) {
  const [release, prerelease] = versionString.split('-')
  const splitRelease = release.split('.').map(number => parseInt(number, 10))

  return {
    major: splitRelease[0],
    minor: splitRelease[1],
    patch: splitRelease[2],
    prerelease: prerelease || '',
    raw: versionString
  }
}
1342688
function getVersion () {
  const url = 'https://raw.githubusercontent.com/mapbox/node-sqlite3/master/package.json'
  return new Promise((resolve, reject) => {
    https.get(url, res => {
      let data = ''
      res.setEncoding('utf8')
      if (res.statusCode !== 200) return reject(res.statusMessage)
      res.on('data', chunk => { data += chunk })
      res.on('end', () => resolve(JSON.parse(data).version))
    })
  })
}
38871
private function getNextVersion($path)
    {
        $file = $path.'/composer.json';

        if (!file_exists($file)) {
            return 'Initial commit';
        }

        $json = json_decode(file_get_contents($file));

        if (!isset($json->version)) {
            return 'Initial commit';
        }

        $ver = explode('.', trim($json->version));
        $min = array_pop($ver);
        $ver[] = $min + 1;
        $json->version = implode('.', $ver);
        $size = file_put_contents(
            $file,
            json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
        );

        if (!$size) {
            $this->error("Error to write file '{$file}'.");
        }

        return 'Version '.$json->version;
    }
1274432
def package_version(filename, varname):
    """"""
    _locals = {}
    with open(filename) as fp:
        exec(fp.read(), None, _locals)
    return _locals[varname]
658268
def get_release(package):
    
    init_path = os.path.join(PROJECT_PATH, package, '__init__.py')
    init_py = open(init_path).read()
    return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)