Make sure wrappers are removed from shell configs when running setup-ci after setup

This commit is contained in:
Reinier Criel 2026-04-07 14:48:20 -07:00
parent 2c568bb2a2
commit f54c9233e1
3 changed files with 69 additions and 0 deletions

View file

@ -1,6 +1,7 @@
import chalk from "chalk";
import { ui } from "../environment/userInteraction.js";
import { getPackageManagerList, knownAikidoTools, getShimsDir } from "./helpers.js";
import { detectShells } from "./shellDetection.js";
import fs from "fs";
import os from "os";
import path from "path";
@ -37,12 +38,33 @@ export async function setupCi() {
fs.mkdirSync(shimsDir, { recursive: true });
}
cleanupLegacyShellInit();
createShims(shimsDir);
ui.writeInformation(`Created shims in ${shimsDir}`);
modifyPathForCi(shimsDir, binDir);
ui.writeInformation(`Added shims directory to PATH for CI environments.`);
}
/**
* Removes shell-based initialization from RC files when switching to --ci install mode.
*/
function cleanupLegacyShellInit() {
let shells;
try {
shells = detectShells();
} catch {
return;
}
for (const shell of shells) {
try {
shell.teardown(knownAikidoTools);
} catch {
// Best-effort cleanup — don't fail the install if teardown errors
}
}
}
/**
* @param {string} shimsDir
*

View file

@ -42,6 +42,13 @@ describe("Setup CI shell integration", () => {
},
});
// Mock shell detection to avoid touching real RC files during tests
mock.module("./shellDetection.js", {
namedExports: {
detectShells: () => [],
},
});
// Mock the helpers module
mock.module("./helpers.js", {
namedExports: {