Spaces:
Paused
Paused
Download node_modules/is-docker/index.js from Shreyansh327/mcp-client: direct link, hf CLI and curl.
- Browser
- Download file 509 Bytes
-
https://huggingface.co/spaces/Shreyansh327/mcp-client/resolve/main/node_modules/is-docker/index.js
- Command line
-
hf download hf://spaces/Shreyansh327/mcp-client/node_modules/is-docker/index.js
-
curl -L -o index.js https://huggingface.co/spaces/Shreyansh327/mcp-client/resolve/main/node_modules/is-docker/index.js
509 Bytes
| import fs from 'node:fs'; | |
| let isDockerCached; | |
| function hasDockerEnv() { | |
| try { | |
| fs.statSync('/.dockerenv'); | |
| return true; | |
| } catch { | |
| return false; | |
| } | |
| } | |
| function hasDockerCGroup() { | |
| try { | |
| return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker'); | |
| } catch { | |
| return false; | |
| } | |
| } | |
| export default function isDocker() { | |
| // TODO: Use `??=` when targeting Node.js 16. | |
| if (isDockerCached === undefined) { | |
| isDockerCached = hasDockerEnv() || hasDockerCGroup(); | |
| } | |
| return isDockerCached; | |
| } | |