-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure ~/.drenv subdirectories are present
Also introduce a constants file to keep reference of cross-command constants, such as important drenv paths.
- Loading branch information
1 parent
2073278
commit 519f313
Showing
9 changed files
with
42 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
import { copy } from "jsr:@std/fs"; | ||
|
||
import { readVersion } from "../utils/read-version.ts"; | ||
import { versionsPath } from "../constants.ts"; | ||
|
||
import global from "./global.ts"; | ||
|
||
export default async function newCommand(name: string) { | ||
return copy( | ||
`${Deno.env.get("HOME")}/.drenv/versions/${await global()}`, | ||
name, | ||
); | ||
return copy(`${versionsPath}/${await global()}`, name); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
import { exists, move } from "jsr:@std/fs"; | ||
import { ensureDir, exists, move } from "jsr:@std/fs"; | ||
|
||
import { binPath, shell } from "../constants.ts"; | ||
|
||
export default async function setup() { | ||
const binPath = `${Deno.env.get("HOME")}/.drenv/bin/drenv`; | ||
const shell = Deno.env.get("SHELL"); | ||
const drenvPath = `${binPath}/drenv`; | ||
|
||
if (await exists(binPath)) { | ||
return "drenv: already installed"; | ||
} else { | ||
if (!Deno.execPath().includes("drenv")) { | ||
return "drenv: this command must be run from the drenv executable" | ||
return "drenv: this command must be run from the drenv executable"; | ||
} | ||
|
||
await move(Deno.execPath(), binPath); | ||
await ensureDir(binPath); | ||
await move(Deno.execPath(), drenvPath); | ||
|
||
console.log(`Installed at ${binPath}\n`); | ||
console.log(`Installed at ${drenvPath}\n`); | ||
console.log(`Run the following to add drenv to your shell profile:\n`); | ||
|
||
if (shell?.includes("zsh")) { | ||
console.log(`echo 'export PATH="$HOME/.drenv/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`); | ||
console.log( | ||
`echo 'export PATH="$HOME/.drenv/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`, | ||
); | ||
} else if (shell?.includes("bash")) { | ||
console.log(`echo 'export PATH="$HOME/.drenv/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc`); | ||
console.log( | ||
`echo 'export PATH="$HOME/.drenv/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc`, | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const homePath = `${Deno.env.get("HOME")}/.drenv`; | ||
export const versionsPath = `${homePath}/versions`; | ||
export const binPath = `${homePath}/bin`; | ||
export const shell = Deno.env.get("SHELL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters