Skip to content

Commit 51fae87

Browse files
committed
Fix support for Podman
Fixes sindresorhus/is-docker#14
1 parent 27e4e3a commit 51fae87

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Diff for: index.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ const localXdgOpenPath = path.join(__dirname, 'xdg-open');
1010

1111
const {platform, arch} = process;
1212

13+
// Podman detection
14+
const hasContainerEnv = () => {
15+
try {
16+
fs.statSync('/run/.containerenv');
17+
return true;
18+
} catch {
19+
return false;
20+
}
21+
};
22+
23+
let cachedResult;
24+
function isInsideContainer() {
25+
if (cachedResult === undefined) {
26+
cachedResult = hasContainerEnv() || isDocker();
27+
}
28+
29+
return cachedResult;
30+
}
31+
1332
/**
1433
Get the mount point for fixed drives in WSL.
1534
@@ -120,7 +139,7 @@ const baseOpen = async options => {
120139
if (app) {
121140
cliArguments.push('-a', app);
122141
}
123-
} else if (platform === 'win32' || (isWsl && !isDocker() && !app)) {
142+
} else if (platform === 'win32' || (isWsl && !isInsideContainer() && !app)) {
124143
const mountPoint = await getWslDrivesMountPoint();
125144

126145
command = isWsl ?

0 commit comments

Comments
 (0)