Skip to content

Commit

Permalink
Fix support for Podman
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Feb 20, 2023
1 parent 27e4e3a commit 51fae87
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ const localXdgOpenPath = path.join(__dirname, 'xdg-open');

const {platform, arch} = process;

// Podman detection
const hasContainerEnv = () => {
try {
fs.statSync('/run/.containerenv');
return true;
} catch {
return false;
}
};

let cachedResult;
function isInsideContainer() {
if (cachedResult === undefined) {
cachedResult = hasContainerEnv() || isDocker();
}

return cachedResult;
}

/**
Get the mount point for fixed drives in WSL.
Expand Down Expand Up @@ -120,7 +139,7 @@ const baseOpen = async options => {
if (app) {
cliArguments.push('-a', app);
}
} else if (platform === 'win32' || (isWsl && !isDocker() && !app)) {
} else if (platform === 'win32' || (isWsl && !isInsideContainer() && !app)) {
const mountPoint = await getWslDrivesMountPoint();

command = isWsl ?
Expand Down

0 comments on commit 51fae87

Please sign in to comment.