summaryrefslogtreecommitdiff
path: root/runtime/js/41_prompt.js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js/41_prompt.js')
-rw-r--r--runtime/js/41_prompt.js18
1 files changed, 7 insertions, 11 deletions
diff --git a/runtime/js/41_prompt.js b/runtime/js/41_prompt.js
index 4e2f0fffc..e9f10e244 100644
--- a/runtime/js/41_prompt.js
+++ b/runtime/js/41_prompt.js
@@ -9,6 +9,8 @@ const {
import { isatty } from "ext:runtime/40_tty.js";
import { stdin } from "ext:deno_io/12_io.js";
+const ops = core.ops;
+
const LF = StringPrototypeCharCodeAt("\n", 0);
const CR = StringPrototypeCharCodeAt("\r", 0);
@@ -35,22 +37,16 @@ function confirm(message = "Confirm") {
}
function prompt(message = "Prompt", defaultValue) {
- defaultValue ??= null;
+ defaultValue ??= "";
if (!isatty(stdin.rid)) {
return null;
}
- if (defaultValue) {
- message += ` [${defaultValue}]`;
- }
-
- message += " ";
-
- // output in one shot to make the tests more reliable
- core.print(message, false);
-
- return readLineFromStdinSync() || defaultValue;
+ return ops.op_read_line_prompt(
+ `${message} `,
+ `${defaultValue}`,
+ );
}
function readLineFromStdinSync() {