bluecodex
Version:
Turn repetitive dev tasks into CLI commands with Typescript
28 lines (21 loc) • 737 B
text/typescript
import { configFile } from "./config-file";
import { findShellProfileFile } from "./find-shell-profile-file";
export async function addSourceConfigResolverInstructionToShellProfile() {
const profileFile = await findShellProfileFile();
const previousContents = (await profileFile.exists())
? await profileFile.read()
: "";
const configShFile = configFile("shell.sh");
const sourceInstruction = `source ${configShFile.tildePath}`;
if (previousContents.includes(sourceInstruction))
return { sourceInstruction };
await profileFile.save(
[
...(previousContents ? [previousContents] : ""),
"",
"# Bluecodex",
sourceInstruction,
].join("\n"),
);
return { sourceInstruction };
}