mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
45 lines
1 KiB
JavaScript
45 lines
1 KiB
JavaScript
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, aikidoCommand } of tools) {
|
|
addLineToFile(
|
|
startupFile,
|
|
`alias ${tool} "${aikidoCommand}" # Safe-chain alias for ${tool}`
|
|
);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
export default {
|
|
name: shellName,
|
|
isInstalled,
|
|
setup,
|
|
teardown,
|
|
};
|