1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

manual - import.meta.main (#1868)

This commit is contained in:
Bartek Iwańczuk 2019-03-02 21:02:47 +01:00 committed by Ryan Dahl
parent bf95acf3eb
commit 39ed975911

View file

@ -472,11 +472,11 @@ software, centralized code repositories, and superfluous file formats.
### Testing if current file is the main program
By using `window.location` and `import.meta.url` one can test if the current
script has been executed as the main input to the program.
To test if the current script has been executed as the main input to the program
check `import.meta.main`.
```ts
if (window.location.toString() == import.meta.url) {
if (import.meta.main) {
console.log("main");
}
```