MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / detectRuntime

Function detectRuntime

scripts/container-runtime.js:37–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35}
36
37function detectRuntime() {
38 if (cachedRuntime) {
39 return cachedRuntime;
40 }
41
42 const override = (process.env.CONTAINER_RUNTIME || process.env.DOCKER_CMD || '').trim().toLowerCase();
43 if (override) {
44 if (!['docker', 'podman'].includes(override)) {
45 console.error(`Invalid CONTAINER_RUNTIME="${process.env.CONTAINER_RUNTIME || process.env.DOCKER_CMD}". Use "docker" or "podman".`);
46 process.exit(1);
47 }
48 const resolved = resolveRuntime(override);
49 if (!resolved) {
50 console.error(`CONTAINER_RUNTIME=${override} but "${override}" is not available on PATH or in WSL.`);
51 process.exit(1);
52 }
53 cachedRuntime = resolved;
54 return cachedRuntime;
55 }
56
57 cachedRuntime = resolveRuntime('docker') || resolveRuntime('podman');
58 return cachedRuntime;
59}
60
61function usesWsl() {
62 const runtime = detectRuntime();

Callers 3

usesWslFunction · 0.85
isAvailableFunction · 0.85
getRuntimeFunction · 0.85

Calls 1

resolveRuntimeFunction · 0.85

Tested by

no test coverage detected