/* * Helper to get an executable */ const getDockerBin = (bin, base) => { // Do platform appropriate things to get started const join = (process.platform === 'win32') ? path.win32.join : path.posix.join; let binPath = (process.platform === 'win32') ? join(base, `${bin}.exe`) : join(base, bin); // Use PATH compose executable on posix if ours does not exist if (process.platform !== 'win32' && (!fs.existsSync(binPath) || fs.statSync(binPath).isDirectory())) { binPath = _.toString(shell.which(bin)); } // If the binpath still does not exist then we should set to false and handle downstream if (!fs.existsSync(binPath)) return false; // Otherwise return a normalized binpath switch (process.platform) { case 'darwin': return path.posix.normalize(binPath); case 'linux': return path.posix.normalize(binPath); case 'win32': return path.win32.normalize(binPath); } }
process.env.ProgramW6432 = 'C:\\Program Files'; const composeExecutable = env.getDockerExecutable(); const value = path.win32.join(env.getDockerBinPath(), 'docker.exe'); expect(composeExecutable).to.equal(value); resetPlatform();
const dockerBinPath = env.getDockerBinPath(); const pf = process.env.ProgramW6432; const value = path.win32.join(pf, 'Docker', 'Docker', 'resources', 'bin'); expect(dockerBinPath).to.equal(value); resetPlatform(); const dockerBinPath = env.getDockerBinPath(); const pf = process.env.ProgramFiles; const value = path.win32.join(pf, 'Docker', 'Docker', 'resources', 'bin'); expect(dockerBinPath).to.equal(value); resetPlatform();
process.env.ProgramW6432 = 'C:\\Program Files'; const composeExecutable = env.getComposeExecutable(); const value = path.win32.join(env.getDockerBinPath(), 'docker-compose.exe'); expect(composeExecutable).to.equal(value); resetPlatform();