Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
mono0x committed May 30, 2024
1 parent e23acec commit 943a772
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions _install/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,20 @@ switch (Deno.build.os) {
}

async function setupRemoteContainer() {
console.log("Installing and initalizing chezmoi");
await $`sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply --verbose ${account}`;
}

async function setupUnix(os: "linux" | "darwin") {
const homeDir = Deno.env.get("HOME");
if (!homeDir) {
console.error("HOME environment variable not set");
Deno.exit(1);
}

if (os === "linux") {
console.log("Installing dependencies");

await aptInstall([
// https://docs.brew.sh/Homebrew-on-Linux
"build-essential",
Expand All @@ -66,16 +75,14 @@ async function setupUnix(os: "linux" | "darwin") {
: "/opt/homebrew";
const brew = path.join(homebrewDir, "bin", "brew");

const homeDir = Deno.env.get("HOME");
if (!homeDir) {
console.error("HOME environment variable not set");
Deno.exit(1);
}
console.log("Installing Homebrew");

if (!await fs.exists(brew)) {
await $`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`;
}

console.log("Installing and initializing chezmoi");

await $`/bin/bash --noprofile --norc`
.stdinText(`
export PATH=$PATH:${scoopShimDir}
Expand All @@ -90,14 +97,14 @@ async function setupUnix(os: "linux" | "darwin") {
}

async function setupWindows() {
// TODO

const homeDir = Deno.env.get("USERPROFILE");
if (!homeDir) {
console.error("USERPROFILE environment variable not set");
Deno.exit(1);
}

console.log("Installing scoop");

const scoopShimDir = path.join(homeDir, "scoop", "shims");
if (!await fs.exists(scoopShimDir)) {
await $`pwsh -noprofile -noninteractive -`
Expand All @@ -107,6 +114,8 @@ async function setupWindows() {
`);
}

console.log("Initializing chezmoi");

const chezmoi = path.join(scoopShimDir, "chezmoi.exe");
await $`pwsh -noprofile -noninteractive -`
.stdinText(`
Expand Down

0 comments on commit 943a772

Please sign in to comment.