diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-05-31 18:48:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-31 13:48:32 -0400 |
commit | 10573183af14b4f303909ee9394e0e72cf10b45d (patch) | |
tree | 45a2136c24d8cbb7d36218f9d1c10432bef301f8 /std/path/posix.ts | |
parent | 464f5bf769f23b85ecc2c99b54b639c5a71d700f (diff) |
fix(std/path): Support browsers (#6003)
Diffstat (limited to 'std/path/posix.ts')
-rw-r--r-- | std/path/posix.ts | 11 |
1 files changed, 8 insertions, 3 deletions
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); |