summaryrefslogtreecommitdiff
path: root/std/path/win32.ts
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-05-31 18:48:32 +0100
committerGitHub <noreply@github.com>2020-05-31 13:48:32 -0400
commit10573183af14b4f303909ee9394e0e72cf10b45d (patch)
tree45a2136c24d8cbb7d36218f9d1c10432bef301f8 /std/path/win32.ts
parent464f5bf769f23b85ecc2c99b54b639c5a71d700f (diff)
fix(std/path): Support browsers (#6003)
Diffstat (limited to 'std/path/win32.ts')
-rw-r--r--std/path/win32.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/std/path/win32.ts b/std/path/win32.ts
index 0557b3768..f556c5b73 100644
--- a/std/path/win32.ts
+++ b/std/path/win32.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, env } = Deno;
-import { FormatInputPathObject, ParsedPath } from "./interface.ts";
+import { FormatInputPathObject, ParsedPath } from "./_interface.ts";
import {
CHAR_DOT,
CHAR_BACKWARD_SLASH,
@@ -32,14 +32,20 @@ export function resolve(...pathSegments: string[]): string {
if (i >= 0) {
path = pathSegments[i];
} else if (!resolvedDevice) {
- path = cwd();
+ if (globalThis.Deno == null) {
+ throw new TypeError("Resolved a drive-letter-less path without a CWD.");
+ }
+ path = Deno.cwd();
} else {
+ if (globalThis.Deno == null) {
+ throw new TypeError("Resolved a relative path without a CWD.");
+ }
// Windows has the concept of drive-specific current working
// directories. If we've resolved a drive letter but not yet an
// absolute path, get cwd for that drive, or the process cwd if
// the drive cwd is not available. We're sure the device is not
// a UNC path at this points, because UNC paths are always absolute.
- path = env.get(`=${resolvedDevice}`) || cwd();
+ path = Deno.env.get(`=${resolvedDevice}`) || Deno.cwd();
// Verify that a cwd was found and that it actually points
// to our drive. If not, default to the drive's root.