From 42408febe8cdf9e30ff8d1a3bb13f4994906c53b Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 12 Feb 2019 21:14:02 -0500 Subject: Add window.location --- website/manual.md | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'website') 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 -- cgit v1.2.3