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:
parent
bf95acf3eb
commit
39ed975911
1 changed files with 3 additions and 3 deletions
|
@ -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");
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue