Skip to content

Commit

Permalink
fix: make cd always relative to starting cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed May 13, 2021
1 parent e73f3a6 commit 111d41c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/runtime/cd.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { error } from "../_utils.ts";

const cwd = Deno.cwd();

export function cd(dir: string) {
if ($.verbose) {
console.log($.brightBlue("$ %s"), `cd ${dir}`);
}
try {
Deno.chdir(dir);
Deno.chdir(new URL(dir, path.toFileUrl(cwd + path.sep)).pathname);
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
const stack: string = (new Error().stack!.split("at ")[2]).trim();
Expand Down

0 comments on commit 111d41c

Please sign in to comment.