mirror of
https://github.com/denoland/deno.git
synced 2024-12-11 10:07:54 -05:00
60688c563e
This commit adds `import.meta.filename` and `import.meta.dirname` APIs. These APIs return string representation of filename and containing dirname. They are only defined for local modules (modules that have `file:///` scheme). Example: ```ts console.log(import.meta.filename, import.meta.dirname) ``` Unix: ``` $ deno run /dev/my_module.ts /dev/my_module.ts /dev/ ``` Windows: ``` $ deno run C:\dev\my_module.ts C:\dev\my_module.ts C:\ ```
7 lines
167 B
TypeScript
7 lines
167 B
TypeScript
console.log(
|
|
import.meta.url.startsWith("http") ? "other remote" : "other",
|
|
import.meta.url,
|
|
import.meta.main,
|
|
import.meta.filename,
|
|
import.meta.dirname,
|
|
);
|