mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Zsh: check if safe-chain is installed before running it.
This commit is contained in:
parent
fe1ca396b4
commit
09300eade6
4 changed files with 177 additions and 45 deletions
|
|
@ -2,6 +2,10 @@ import chalk from "chalk";
|
|||
import { ui } from "../environment/userInteraction.js";
|
||||
import { detectShells } from "./shellDetection.js";
|
||||
import { knownAikidoTools } from "./helpers.js";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
/**
|
||||
* Loops over the detected shells and calls the setup function for each.
|
||||
|
|
@ -13,6 +17,8 @@ export async function setup() {
|
|||
);
|
||||
ui.emptyLine();
|
||||
|
||||
copyStartupFiles();
|
||||
|
||||
try {
|
||||
const shells = detectShells();
|
||||
if (shells.length === 0) {
|
||||
|
|
@ -72,3 +78,23 @@ function setupShell(shell) {
|
|||
|
||||
return success;
|
||||
}
|
||||
|
||||
function copyStartupFiles() {
|
||||
const startupFiles = ["init-zsh.sh"];
|
||||
|
||||
for (const file of startupFiles) {
|
||||
const targetPath = path.join(os.homedir(), ".safe-chain", "scripts", file);
|
||||
|
||||
// Create target directory if it doesn't exist
|
||||
const targetDir = targetPath.substring(0, targetPath.lastIndexOf("/"));
|
||||
if (!fs.existsSync(targetDir)) {
|
||||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Use absolute path for source
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const sourcePath = path.resolve(__dirname, "startup-scripts", file);
|
||||
fs.copyFileSync(sourcePath, targetPath);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue