mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Add env var support for home dir
This commit is contained in:
parent
698a12082d
commit
a0fb8d6b3d
4 changed files with 125 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ import * as os from "os";
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { ECOSYSTEM_JS, ECOSYSTEM_PY } from "../config/settings.js";
|
||||
import { getSafeChainDir } from "../config/environmentVariables.js";
|
||||
import { safeSpawn } from "../utils/safeSpawn.js";
|
||||
import { ui } from "../environment/userInteraction.js";
|
||||
|
||||
|
|
@ -121,18 +122,34 @@ export function getPackageManagerList() {
|
|||
return `${tools.join(", ")}, and ${lastTool} commands`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the safe-chain base directory.
|
||||
* Uses SAFE_CHAIN_DIR environment variable when set, otherwise defaults to ~/.safe-chain.
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getSafeChainBaseDir() {
|
||||
return getSafeChainDir() ?? path.join(os.homedir(), ".safe-chain");
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getBinDir() {
|
||||
return path.join(getSafeChainBaseDir(), "bin");
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getShimsDir() {
|
||||
return path.join(os.homedir(), ".safe-chain", "shims");
|
||||
return path.join(getSafeChainBaseDir(), "shims");
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getScriptsDir() {
|
||||
return path.join(os.homedir(), ".safe-chain", "scripts");
|
||||
return path.join(getSafeChainBaseDir(), "scripts");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue