Skip to content

Commit

Permalink
Move DR installation instead of copying
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitemaeric committed Oct 17, 2024
1 parent 73cfb6c commit ca80abf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from "npm:commander";
import { copy } from "jsr:@std/fs";
import { copy, move } from "jsr:@std/fs";

import global from "./commands/global.ts";

Expand All @@ -22,12 +22,12 @@ const actionRunner = (fn: (...args: any[]) => Promise<any>) => {

program
.name("drenv")
.description("CLI to manage DragonRuby environments")
.version("0.1.0");
.description("CLI to manage DragonRuby environments.")
.version("0.1.1");

program.command("new")
.argument("<name>", "Name of the new project")
.description("Create a new DragonRuby project")
.description("Create a new DragonRuby project.")
.action(async (name) => {
await copy(
`${Deno.env.get("HOME")}/.drenv/versions/${await global()}`,
Expand All @@ -37,21 +37,21 @@ program.command("new")

program.command("register")
.argument("<path>", "Path to a fresh DragonRuby directory")
.description("Register a DragonRuby installation")
.description("Register a DragonRuby installation. This moves the installation to the $HOME/.drenv directory.")
.action(async (path) => {
const content = await readFirstLine(path + "/CHANGELOG-CURR.txt");
const version = content.match(/[0-9\.]+/)?.[0];

await copy(path, `${Deno.env.get("HOME")}/.drenv/versions/${version}`);
await move(path, `${Deno.env.get("HOME")}/.drenv/versions/${version}`);
});

program.command("global")
.argument("[version]", "Version of DragonRuby to use")
.description("Get or set the global version of DragonRuby")
.description("Get or set the global version of DragonRuby.")
.action(actionRunner(global));

program.command("versions")
.description("List out all locally installed versions of DragonRuby")
.description("List out all locally installed versions of DragonRuby.")
.action(async (options) => {
const directories = await Deno.readDir(
`${Deno.env.get("HOME")}/.drenv/versions/`,
Expand Down

0 comments on commit ca80abf

Please sign in to comment.