summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/integration/run_tests.rs1
-rw-r--r--cli/tests/testdata/run/import_meta/main.out5
-rw-r--r--cli/tests/testdata/run/import_meta/main.ts12
-rw-r--r--cli/tests/testdata/run/import_meta/other.ts8
-rw-r--r--cli/tsc/dts/lib.deno.ns.d.ts30
5 files changed, 50 insertions, 6 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 429ec2a04..3a2b46133 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -1493,6 +1493,7 @@ itest!(if_main {
itest!(import_meta {
args: "run --quiet --reload --import-map=run/import_meta/importmap.json run/import_meta/main.ts",
output: "run/import_meta/main.out",
+ http_server: true,
});
itest!(main_module {
diff --git a/cli/tests/testdata/run/import_meta/main.out b/cli/tests/testdata/run/import_meta/main.out
index 0329dea8a..5a86d6240 100644
--- a/cli/tests/testdata/run/import_meta/main.out
+++ b/cli/tests/testdata/run/import_meta/main.out
@@ -1,5 +1,6 @@
-other [WILDCARD]other.ts false
-main [WILDCARD]main.ts true
+other remote [WILDCARD]other.ts false undefined undefined
+other [WILDCARD]other.ts false [WILDCARD]other.ts [WILDCARD]
+main [WILDCARD]main.ts true [WILDCARD]main.ts [WILDCARD]
Resolving ./foo.js file:///[WILDCARD]/foo.js
Resolving bare from import map https://example.com/
Resolving https://example.com/rewrite from import map https://example.com/rewritten
diff --git a/cli/tests/testdata/run/import_meta/main.ts b/cli/tests/testdata/run/import_meta/main.ts
index 96d63ba78..fb859e250 100644
--- a/cli/tests/testdata/run/import_meta/main.ts
+++ b/cli/tests/testdata/run/import_meta/main.ts
@@ -1,9 +1,15 @@
import { assertThrows } from "../../../../../test_util/std/assert/mod.ts";
-
-console.log("main", import.meta.url, import.meta.main);
-
+import "http://localhost:4545/run/import_meta/other.ts";
import "./other.ts";
+console.log(
+ "main",
+ import.meta.url,
+ import.meta.main,
+ import.meta.filename,
+ import.meta.dirname,
+);
+
console.log("Resolving ./foo.js", import.meta.resolve("./foo.js"));
console.log("Resolving bare from import map", import.meta.resolve("bare"));
console.log(
diff --git a/cli/tests/testdata/run/import_meta/other.ts b/cli/tests/testdata/run/import_meta/other.ts
index 47d7527cd..5da6a4936 100644
--- a/cli/tests/testdata/run/import_meta/other.ts
+++ b/cli/tests/testdata/run/import_meta/other.ts
@@ -1 +1,7 @@
-console.log("other", import.meta.url, import.meta.main);
+console.log(
+ import.meta.url.startsWith("http") ? "other remote" : "other",
+ import.meta.url,
+ import.meta.main,
+ import.meta.filename,
+ import.meta.dirname,
+);
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts
index 8d1e28d4b..483c5c3d0 100644
--- a/cli/tsc/dts/lib.deno.ns.d.ts
+++ b/cli/tsc/dts/lib.deno.ns.d.ts
@@ -28,6 +28,36 @@ declare interface ImportMeta {
*/
url: string;
+ /** The absolute path of the current module.
+ *
+ * This property is only provided for local modules (ie. using `file://` URLs).
+ *
+ * Example:
+ * ```
+ * // Unix
+ * console.log(import.meta.filename); // /home/alice/my_module.ts
+ *
+ * // Windows
+ * console.log(import.meta.filename); // C:\alice\my_module.ts
+ * ```
+ */
+ filename?: string;
+
+ /** The absolute path of the dirrectory containing the current module.
+ *
+ * This property is only provided for local modules (ie. using `file://` URLs).
+ *
+ * * Example:
+ * ```
+ * // Unix
+ * console.log(import.meta.dirname); // /home/alice/
+ *
+ * // Windows
+ * console.log(import.meta.dirname); // C:\alice\
+ * ```
+ */
+ dirname?: string;
+
/** A flag that indicates if the current module is the main module that was
* called when starting the program under Deno.
*