MCPcopy Index your code
hub / github.com/github/awesome-copilot / augmentedEnv

Function augmentedEnv

extensions/java-modernization-studio/doctor.mjs:69–89  ·  view source on GitHub ↗
(env, plat, lister)

Source from the content-addressed store, hash-verified

67 * lister (so it's unit-testable without hitting the filesystem).
68 */
69export function augmentedEnv(env, plat, lister) {
70 const base = Object.assign({}, env);
71 if (plat === "win32") return base; // Windows PATH semantics differ; leave as-is.
72 const ls = lister || ((d) => { try { return readdirSync(d); } catch (e) { return []; } });
73 const extra = ["/opt/homebrew/bin", "/opt/homebrew/sbin", "/usr/local/bin", "/usr/local/sbin"];
74 if (base.HOME) {
75 extra.push(base.HOME + "/.sdkman/candidates/java/current/bin");
76 extra.push(base.HOME + "/.asdf/shims");
77 }
78 if (base.JAVA_HOME) extra.push(base.JAVA_HOME + "/bin");
79 // Keg-only Homebrew JDKs aren't symlinked into .../bin, so enumerate them.
80 for (const root of ["/opt/homebrew/opt", "/usr/local/opt"]) {
81 for (const name of ls(root)) {
82 if (/^openjdk(@\d+)?$/.test(name)) extra.push(root + "/" + name + "/libexec/openjdk.jdk/Contents/Home/bin");
83 }
84 }
85 const seen = {};
86 const prefix = extra.filter((p) => { if (seen[p]) return false; seen[p] = 1; return true; });
87 base.PATH = prefix.join(":") + (base.PATH ? ":" + base.PATH : "");
88 return base;
89}
90
91/** Build an exec function bound to a specific environment. */
92export function makeExec(env) {

Callers 3

cockpit.test.mjsFile · 0.90
defaultExecFunction · 0.85
runDoctorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected