Skip to content

Commit

Permalink
fix: use data url to import local file
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed May 8, 2021
1 parent d9bb2f9 commit 9be2e02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { join } from "https://deno.land/std@0.95.0/path/mod.ts";
export { colors } from "https://deno.land/x/cliffy@v0.18.2/ansi/colors.ts";
export { iter } from "https://deno.land/std@0.95.0/io/util.ts";
export { encode } from "https://deno.land/std@0.84.0/encoding/base64.ts";
5 changes: 4 additions & 1 deletion dzx.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { encode } from "./deps.ts";
import { DZX } from "./types.d.ts";
import { colors, iter, join } from "./deps.ts";
import { ProcessResult } from "./process_result.ts";
Expand All @@ -12,7 +13,9 @@ window.$ = $;
const script: string | undefined = Deno.args[0];

if (script) {
await import(join(Deno.cwd(), script));
const url = join(Deno.cwd(), script);
const content = await Deno.readTextFile(url);
await import(`data:application/typescript;base64,${encode(content)}`);
} else {
console.error("missing script");
Deno.exit(0);
Expand Down

0 comments on commit 9be2e02

Please sign in to comment.