makitso-prompt
Advanced tools
Comparing version 1.0.2 to 1.0.3
12
index.js
@@ -393,3 +393,3 @@ const _forEach = require("lodash/forEach"); | ||
renderPromptLine(state) { | ||
debug({ renderPromptLine: state }); | ||
// debug({ renderPromptLine: state }); | ||
const prompt = state.prompt.text; | ||
@@ -440,3 +440,3 @@ const cmd = this.renderCommand(state); | ||
render({ state, prevState, output }) { | ||
debug({ render: { prevState, state } }); | ||
// debug({ render: { prevState, state } }); | ||
@@ -448,9 +448,7 @@ if (state === prevState) { | ||
if (this.headerChanged(prevState, state)) { | ||
let rows = 0; | ||
if (prevState.header) { | ||
const { rows } = getEndOfLinePos( | ||
this.output.columns, | ||
prevState.header | ||
); | ||
clearLinesAbove(this.output, rows + 1); | ||
({ rows } = getEndOfLinePos(this.output.columns, prevState.header)); | ||
} | ||
clearLinesAbove(output, rows + 1); | ||
output.write(`${state.header}`); | ||
@@ -457,0 +455,0 @@ if (state.header.length) { |
{ | ||
"name": "makitso-prompt", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "a terminal prompt", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -31,12 +31,20 @@ const { Writable } = require("stream"); | ||
function parseOutput(output, rows) { | ||
const terminal = new AnsiTerminal(80, (rows = 10), 0); | ||
const parser = new AnsiParser(terminal); | ||
parser.parse(output); | ||
return terminal.toString().replace(/\n+$/, ""); | ||
} | ||
async function getResult(prompt, output, rows) { | ||
await waitForKeyPressProcessing(prompt); | ||
const terminal = new AnsiTerminal(80, (rows = 10), 0); | ||
const parser = new AnsiParser(terminal); | ||
parser.parse(output.data); | ||
const result = terminal.toString().replace(/\n+$/, ""); | ||
debug({ result, outputData: output.data }); | ||
const result = parseOutput(output.data, rows); | ||
return result; | ||
} | ||
module.exports = { newOutput, waitForKeyPressProcessing, getResult }; | ||
module.exports = { | ||
newOutput, | ||
waitForKeyPressProcessing, | ||
parseOutput, | ||
getResult | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172897
27
1730