Refactor to customize shell integration per shell

This commit is contained in:
Sander Declerck 2025-07-17 16:35:03 +02:00
parent 21cdefadde
commit fe1ca396b4
No known key found for this signature in database
16 changed files with 1302 additions and 780 deletions

View file

@ -0,0 +1,45 @@
import {
addLineToFile,
doesExecutableExistOnSystem,
execAndGetOutput,
removeLinesMatchingPattern,
} from "../helpers.js";
const shellName = "Fish";
const executableName = "fish";
const startupFileCommand = "echo ~/.config/fish/config.fish";
function isInstalled() {
return doesExecutableExistOnSystem(executableName);
}
function teardown() {
const startupFile = execAndGetOutput(startupFileCommand, executableName);
// Removes all aliases starting with "alias npm=", "alias npx=", or "alias yarn="
// This will remove the safe-chain aliases for npm, npx, and yarn commands.
removeLinesMatchingPattern(startupFile, /^alias\s+(npm|npx|yarn)\s+/);
return true;
}
function setup(tools) {
const startupFile = execAndGetOutput(startupFileCommand, executableName);
teardown();
for (const tool of tools) {
addLineToFile(
startupFile,
`alias ${tool} "aikido-${tool}" # Safe-chain alias for ${tool}`
);
}
return true;
}
export default {
name: shellName,
isInstalled,
setup,
teardown,
};