fix: resolve gcloud python path
This commit is contained in:
@@ -60,4 +60,55 @@ describe("ensureClawdisCliOnPath", () => {
|
||||
else process.env.CLAWDIS_PATH_BOOTSTRAPPED = originalFlag;
|
||||
}
|
||||
});
|
||||
|
||||
it("prepends mise shims when available", async () => {
|
||||
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "clawdis-path-"));
|
||||
const originalPath = process.env.PATH;
|
||||
const originalFlag = process.env.CLAWDIS_PATH_BOOTSTRAPPED;
|
||||
const originalMiseDataDir = process.env.MISE_DATA_DIR;
|
||||
try {
|
||||
const relayDir = path.join(tmp, "Relay");
|
||||
await fs.mkdir(relayDir, { recursive: true });
|
||||
const relayCli = path.join(relayDir, "clawdis");
|
||||
await fs.writeFile(relayCli, "#!/bin/sh\necho ok\n", "utf-8");
|
||||
await fs.chmod(relayCli, 0o755);
|
||||
|
||||
const localBinDir = path.join(tmp, "node_modules", ".bin");
|
||||
await fs.mkdir(localBinDir, { recursive: true });
|
||||
const localCli = path.join(localBinDir, "clawdis");
|
||||
await fs.writeFile(localCli, "#!/bin/sh\necho ok\n", "utf-8");
|
||||
await fs.chmod(localCli, 0o755);
|
||||
|
||||
const miseDataDir = path.join(tmp, "mise");
|
||||
const shimsDir = path.join(miseDataDir, "shims");
|
||||
await fs.mkdir(shimsDir, { recursive: true });
|
||||
process.env.MISE_DATA_DIR = miseDataDir;
|
||||
process.env.PATH = "/usr/bin";
|
||||
delete process.env.CLAWDIS_PATH_BOOTSTRAPPED;
|
||||
|
||||
ensureClawdisCliOnPath({
|
||||
execPath: relayCli,
|
||||
cwd: tmp,
|
||||
homeDir: tmp,
|
||||
platform: "darwin",
|
||||
});
|
||||
|
||||
const updated = process.env.PATH ?? "";
|
||||
const parts = updated.split(path.delimiter);
|
||||
const relayIndex = parts.indexOf(relayDir);
|
||||
const localIndex = parts.indexOf(localBinDir);
|
||||
const shimsIndex = parts.indexOf(shimsDir);
|
||||
expect(relayIndex).toBeGreaterThanOrEqual(0);
|
||||
expect(localIndex).toBeGreaterThan(relayIndex);
|
||||
expect(shimsIndex).toBeGreaterThan(localIndex);
|
||||
} finally {
|
||||
process.env.PATH = originalPath;
|
||||
if (originalFlag === undefined)
|
||||
delete process.env.CLAWDIS_PATH_BOOTSTRAPPED;
|
||||
else process.env.CLAWDIS_PATH_BOOTSTRAPPED = originalFlag;
|
||||
if (originalMiseDataDir === undefined) delete process.env.MISE_DATA_DIR;
|
||||
else process.env.MISE_DATA_DIR = originalMiseDataDir;
|
||||
await fs.rm(tmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -70,6 +70,11 @@ function candidateBinDirs(opts: EnsureClawdisPathOpts): string[] {
|
||||
if (isExecutable(path.join(localBinDir, "clawdis")))
|
||||
candidates.push(localBinDir);
|
||||
|
||||
const miseDataDir =
|
||||
process.env.MISE_DATA_DIR ?? path.join(homeDir, ".local", "share", "mise");
|
||||
const miseShims = path.join(miseDataDir, "shims");
|
||||
if (isDirectory(miseShims)) candidates.push(miseShims);
|
||||
|
||||
// Common global install locations (macOS first).
|
||||
if (platform === "darwin") {
|
||||
candidates.push(path.join(homeDir, "Library", "pnpm"));
|
||||
|
||||
Reference in New Issue
Block a user