File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 1
1
/// <reference path="./types.d.ts" />
2
2
3
- import { join , readAll } from "./deps.ts" ;
3
+ import { readAll } from "./deps.ts" ;
4
+ import { join } from "./deps.ts" ;
4
5
import { ProcessError } from "./src/process_error.ts" ;
5
6
import { $ } from "./mod.ts" ;
6
7
7
8
window . $ = $ ;
8
9
9
- const script : string | undefined = Deno . args [ 0 ] ;
10
+ let script : string | undefined = Deno . args [ 0 ] ;
10
11
11
12
try {
12
13
if ( ! script ) {
13
14
if ( ! Deno . isatty ( Deno . stdin . rid ) ) {
14
- const data = new TextDecoder ( ) . decode ( await readAll ( Deno . stdin ) ) ;
15
- if ( data ) {
15
+ script = new TextDecoder ( ) . decode ( await readAll ( Deno . stdin ) ) ;
16
+ if ( script ) {
16
17
await import (
17
- `data:application/typescript,${ encodeURIComponent ( data ) } `
18
+ `data:application/typescript,${ encodeURIComponent ( script ) } `
18
19
) ;
19
20
} else {
20
21
console . error ( `usage: dzx <script>` ) ;
24
25
} else if ( script . startsWith ( "http://" ) || script . startsWith ( "https://" ) ) {
25
26
await import ( script ) ;
26
27
} else if ( script ) {
27
- await import ( join ( $ . cwd , script ) ) ;
28
- // const data = await Deno.readTextFile(join($.cwd, script));
29
- // await import(`data:application/typescript,${encodeURIComponent(data)}`);
28
+ const data = await Deno . readTextFile ( join ( $ . cwd , script ) ) ;
29
+ await import ( `data:application/typescript,${ encodeURIComponent ( data ) } ` ) ;
30
30
} else {
31
31
console . error ( `usage: dzx <script>` ) ;
32
32
Deno . exit ( 1 ) ;
You can’t perform that action at this time.
0 commit comments