@inquirer/core
Advanced tools
Comparing version 0.0.15-alpha.0 to 0.0.16-alpha.0
78
hooks.js
@@ -73,52 +73,48 @@ const readline = require('readline'); | ||
exports.useRef = (val) => { | ||
return exports.useState({ current: val })[0]; | ||
}; | ||
exports.useRef = (val) => exports.useState({ current: val })[0]; | ||
exports.createPrompt = (view) => { | ||
return (options) => { | ||
// Default `input` to stdin | ||
const input = process.stdin; | ||
exports.createPrompt = (view) => (options) => { | ||
// Default `input` to stdin | ||
const input = process.stdin; | ||
// Add mute capabilities to the output | ||
const output = new MuteStream(); | ||
output.pipe(process.stdout); | ||
// Add mute capabilities to the output | ||
const output = new MuteStream(); | ||
output.pipe(process.stdout); | ||
const rl = readline.createInterface({ | ||
terminal: true, | ||
input, | ||
output, | ||
}); | ||
const screen = new ScreenManager(rl); | ||
const rl = readline.createInterface({ | ||
terminal: true, | ||
input, | ||
output, | ||
}); | ||
const screen = new ScreenManager(rl); | ||
return new Promise((resolve, reject) => { | ||
sessionRl = rl; | ||
return new Promise((resolve, reject) => { | ||
sessionRl = rl; | ||
const done = (value) => { | ||
let len = cleanupHook.length; | ||
while (len--) { | ||
cleanupHook(len); | ||
} | ||
screen.done(); | ||
const done = (value) => { | ||
let len = cleanupHook.length; | ||
while (len--) { | ||
cleanupHook(len); | ||
} | ||
screen.done(); | ||
// Reset hooks state | ||
hooks = []; | ||
index = 0; | ||
sessionRl = undefined; | ||
// Reset hooks state | ||
hooks = []; | ||
index = 0; | ||
sessionRl = undefined; | ||
// Finally we resolve our promise | ||
resolve(value); | ||
}; | ||
// Finally we resolve our promise | ||
resolve(value); | ||
}; | ||
hooks = []; | ||
const workLoop = (config) => { | ||
index = 0; | ||
handleChange = () => workLoop(config); | ||
screen.render(...[view(config, done)].flat().filter(Boolean)); | ||
}; | ||
hooks = []; | ||
const workLoop = (config) => { | ||
index = 0; | ||
handleChange = () => workLoop(config); | ||
screen.render(...[view(config, done)].flat().filter(Boolean)); | ||
}; | ||
// TODO: we should display a loader while we get the default options. | ||
getPromptConfig(options).then(workLoop, reject); | ||
}); | ||
}; | ||
// TODO: we should display a loader while we get the default options. | ||
getPromptConfig(options).then(workLoop, reject); | ||
}); | ||
}; |
{ | ||
"name": "@inquirer/core", | ||
"version": "0.0.15-alpha.0", | ||
"version": "0.0.16-alpha.0", | ||
"description": "Core Inquirer prompt API", | ||
@@ -29,3 +29,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "0053e3f5694a4f75c4901512ab87e8906d1d7896" | ||
"gitHead": "9bee59b98465656619e4ee563ddbc466dcf2b4f1" | ||
} |
26647
749