From 10573183af14b4f303909ee9394e0e72cf10b45d Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Sun, 31 May 2020 18:48:32 +0100 Subject: fix(std/path): Support browsers (#6003) --- std/path/posix.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'std/path/posix.ts') diff --git a/std/path/posix.ts b/std/path/posix.ts index e88eb3f97..365232e33 100644 --- a/std/path/posix.ts +++ b/std/path/posix.ts @@ -1,8 +1,8 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ +/** This module is browser compatible. */ -const { cwd } = Deno; -import { FormatInputPathObject, ParsedPath } from "./interface.ts"; +import { FormatInputPathObject, ParsedPath } from "./_interface.ts"; import { CHAR_DOT, CHAR_FORWARD_SLASH } from "./_constants.ts"; import { @@ -24,7 +24,12 @@ export function resolve(...pathSegments: string[]): string { let path: string; if (i >= 0) path = pathSegments[i]; - else path = cwd(); + else { + if (globalThis.Deno == null) { + throw new TypeError("Resolved a relative path without a CWD."); + } + path = Deno.cwd(); + } assertPath(path); -- cgit v1.2.3