MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / parseRunner

Function parseRunner

src/index.ts:76–93  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

74}
75
76function parseRunner(args: string[]): "npx" | "bunx" {
77 const explicit = args.find((arg) => arg.startsWith("--runner="));
78 if (explicit) {
79 const value = explicit.split("=")[1];
80 if (value === "npx" || value === "bunx") return value;
81 throw new Error(`Unsupported runner \"${value}\". Use --runner=npx or --runner=bunx.`);
82 }
83 const runnerFlagIndex = args.findIndex((arg) => arg === "--runner");
84 if (runnerFlagIndex >= 0) {
85 const value = args[runnerFlagIndex + 1];
86 if (value === "npx" || value === "bunx") return value;
87 throw new Error(`Unsupported runner \"${value}\". Use --runner=npx or --runner=bunx.`);
88 }
89 const userAgent = (process.env.npm_config_user_agent ?? "").toLowerCase();
90 const execPath = (process.env.npm_execpath ?? "").toLowerCase();
91 if (userAgent.includes("bun/") || execPath.includes("bun")) return "bunx";
92 return "npx";
93}
94
95function buildMcpConfig(runner: "npx" | "bunx") {
96 const commandArgs = runner === "npx" ? ["-y", "contextplus"] : ["contextplus"];

Callers 1

runInitCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected