Commit e736d0f 1 parent 1c18898 commit e736d0f Copy full SHA for e736d0f
File tree 2 files changed +9
-6
lines changed
2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
2
2
( ( window ) => {
3
- const { stdin, stdout } = window . __bootstrap . files ;
3
+ const { stdin } = window . __bootstrap . files ;
4
4
const { isatty } = window . __bootstrap . tty ;
5
5
const LF = "\n" . charCodeAt ( 0 ) ;
6
6
const CR = "\r" . charCodeAt ( 0 ) ;
7
- const encoder = new TextEncoder ( ) ;
8
7
const decoder = new TextDecoder ( ) ;
8
+ const core = window . Deno . core ;
9
9
10
10
function alert ( message = "Alert" ) {
11
11
if ( ! isatty ( stdin . rid ) ) {
12
12
return ;
13
13
}
14
14
15
- stdout . writeSync ( encoder . encode ( `${ message } [Enter] ` ) ) ;
15
+ core . print ( `${ message } [Enter] ` , false ) ;
16
16
17
17
readLineFromStdinSync ( ) ;
18
18
}
22
22
return false ;
23
23
}
24
24
25
- stdout . writeSync ( encoder . encode ( `${ message } [y/N] ` ) ) ;
25
+ core . print ( `${ message } [y/N] ` , false ) ;
26
26
27
27
const answer = readLineFromStdinSync ( ) ;
28
28
36
36
return null ;
37
37
}
38
38
39
- stdout . writeSync ( encoder . encode ( `${ message } ` ) ) ;
39
+ core . print ( `${ message } ` , false ) ;
40
40
41
41
if ( defaultValue ) {
42
- stdout . writeSync ( encoder . encode ( `[${ defaultValue } ] ` ) ) ;
42
+ core . print ( `[${ defaultValue } ] ` , false ) ;
43
43
}
44
44
45
45
return readLineFromStdinSync ( ) || defaultValue ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ use futures::future::FutureExt;
11
11
use rusty_v8 as v8;
12
12
use std:: cell:: Cell ;
13
13
use std:: convert:: TryFrom ;
14
+ use std:: io:: { stdout, Write } ;
14
15
use std:: option:: Option ;
15
16
use url:: Url ;
16
17
use v8:: MapFnTo ;
@@ -352,8 +353,10 @@ fn print(
352
353
} ;
353
354
if is_err {
354
355
eprint ! ( "{}" , str_. to_rust_string_lossy( tc_scope) ) ;
356
+ stdout ( ) . flush ( ) . unwrap ( ) ;
355
357
} else {
356
358
print ! ( "{}" , str_. to_rust_string_lossy( tc_scope) ) ;
359
+ stdout ( ) . flush ( ) . unwrap ( ) ;
357
360
}
358
361
}
359
362
You can’t perform that action at this time.
0 commit comments