summaryrefslogtreecommitdiff
path: root/std/path/win32.ts
diff options
context:
space:
mode:
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.