renovate/lib/workers/global/versions.js
Rhys Arkins 47044a11e1 feat(yarn): Use embedded yarn version (#510)
Renovate now uses an embedded yarn binary. This way, the version of yarn used can be known + there is no requirement for Renovate admins to install yarn separately.
2017-07-21 08:47:05 +02:00

25 lines
696 B
JavaScript

const cp = require('child_process');
const tmp = require('tmp');
const root = require('root-require');
module.exports = {
detectVersions,
};
function detectVersions(config) {
config.logger.debug('Detecting versions');
const versions = {};
try {
versions.renovate = root('package.json').version;
const tmpDir = tmp.dirSync({ unsafeCleanup: true });
const result = cp.spawnSync('npm', ['--version'], {
cwd: tmpDir.name,
shell: true,
});
versions.npm = result.stdout.toString().split('\n')[0];
} catch (err) {
config.logger.error({ err }, 'Error detecting versions');
}
config.logger.debug({ versions }, 'Detected versions');
return versions;
}