diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-02-12 21:14:02 -0500 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-18 23:04:59 -0500 |
commit | 42408febe8cdf9e30ff8d1a3bb13f4994906c53b (patch) | |
tree | 92ab3408d426f1d18a511aa16130357ed074410a /website/manual.md | |
parent | 27afbd135162b435c8af22b18622656ccab12174 (diff) |
Add window.location
Diffstat (limited to 'website/manual.md')
-rw-r--r-- | website/manual.md | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/website/manual.md b/website/manual.md index 5a9add63e..524f1d449 100644 --- a/website/manual.md +++ b/website/manual.md @@ -466,6 +466,17 @@ import { test, assertEqual } from "./package.ts"; This design circumvents a plethora of complexity spawned by package management 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. + +```ts +if (window.location.toString() == import.meta.url) { + console.log("main"); +} +``` + ## Command line interface ### Flags |