mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Initial commit
This commit is contained in:
parent
dd51a48435
commit
5eaf6ac3b3
51 changed files with 10087 additions and 1 deletions
44
src/shell-integration/helpers.js
Normal file
44
src/shell-integration/helpers.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
const knownAikidoTools = [
|
||||
{ tool: "npm", aikidoCommand: "aikido-npm" },
|
||||
{ tool: "npx", aikidoCommand: "aikido-npx" },
|
||||
{ tool: "yarn", aikidoCommand: "aikido-yarn" },
|
||||
// When adding a new tool here, also update the expected alias in the tests (shellIntegration.spec.js)
|
||||
// and add the documentation for the new tool in the README.md
|
||||
];
|
||||
|
||||
export function getAliases(fileName) {
|
||||
const fileExtension = fileName.split(".").pop().toLowerCase();
|
||||
|
||||
let createAlias = pickCreateAliasFunction(fileExtension);
|
||||
|
||||
const aliases = knownAikidoTools.map(({ tool, aikidoCommand }) =>
|
||||
createAlias(tool, aikidoCommand)
|
||||
);
|
||||
|
||||
return aliases;
|
||||
}
|
||||
|
||||
function pickCreateAliasFunction(fileExtension) {
|
||||
let createAlias;
|
||||
switch (fileExtension) {
|
||||
case "ps1":
|
||||
createAlias = createGeneralPowershellAlias;
|
||||
break;
|
||||
case "fish":
|
||||
createAlias = createGeneralFishAlias;
|
||||
break;
|
||||
default:
|
||||
createAlias = createGeneralPosixAlias;
|
||||
}
|
||||
return createAlias;
|
||||
}
|
||||
|
||||
function createGeneralPosixAlias(tool, aikidoCommand) {
|
||||
return `alias ${tool}='${aikidoCommand}'`;
|
||||
}
|
||||
function createGeneralPowershellAlias(tool, aikidoCommand) {
|
||||
return `Set-Alias ${tool} ${aikidoCommand}`;
|
||||
}
|
||||
function createGeneralFishAlias(tool, aikidoCommand) {
|
||||
return `alias ${tool} "${aikidoCommand}"`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue