Skip to content

Commit

Permalink
feat(pipenv): Use centralized docker execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Zharinov committed Dec 24, 2019
1 parent 5bb0fd7 commit 9ef77d5
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions lib/manager/pipenv/artifacts.ts
@@ -1,6 +1,6 @@
import { ensureDir, outputFile, readFile } from 'fs-extra';
import { join, dirname } from 'upath';
import { exec } from '../../util/exec';
import { exec, ExecOptions } from '../../util/exec';
import { getChildProcessEnv } from '../../util/env';
import { logger } from '../../logger';
import { UpdateArtifactsResult, UpdateArtifactsConfig } from '../common';
Expand Down Expand Up @@ -32,29 +32,24 @@ export async function updateArtifacts(
const localLockFileName = join(config.localDir, lockFileName);
const env = getChildProcessEnv(['LC_ALL', 'LANG', 'PIPENV_CACHE_DIR']);
const startTime = process.hrtime();
let cmd: string;
const cmd: string = 'pipenv';
const execOptions: ExecOptions = { cwd, env };
if (config.binarySource === 'docker') {
logger.info('Running pipenv via docker');
cmd = `docker run --rm `;
if (config.dockerUser) {
cmd += `--user=${config.dockerUser} `;
}
const volumes = [config.localDir, process.env.PIPENV_CACHE_DIR];
cmd += volumes.map(v => `-v "${v}":"${v}" `).join('');
const envVars = ['LC_ALL', 'LANG', 'PIPENV_CACHE_DIR'];
cmd += envVars.map(e => `-e ${e} `).join('');
cmd += `-w "${cwd}" `;
cmd += `renovate/pipenv pipenv`;
execOptions.docker = {
image: 'renovate/pipenv',
tag: null,
dockerUser: config.dockerUser,
volumes: [config.localDir, process.env.PIPENV_CACHE_DIR],
envVars: ['LC_ALL', 'LANG', 'PIPENV_CACHE_DIR'],
cwd,
};
} else {
logger.info('Running pipenv via global command');
cmd = 'pipenv';
}
const args = 'lock';
logger.debug({ cmd, args }, 'pipenv lock command');
({ stdout, stderr } = await exec(`${cmd} ${args}`, {
cwd,
env,
}));
({ stdout, stderr } = await exec(`${cmd} ${args}`, execOptions));
const duration = process.hrtime(startTime);
const seconds = Math.round(duration[0] + duration[1] / 1e9);
stdout = stdout ? stdout.replace(/(Locking|Running)[^\s]*?\s/g, '') : null;
Expand Down

0 comments on commit 9ef77d5

Please sign in to comment.