This commit is contained in:
Reinier Criel 2026-04-15 06:37:51 +09:00 committed by GitHub
commit cd8b26245b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 70 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,34 @@ 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 {
// Best-effort cleanup — skip if shell detection fails
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: {