New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show diffs in System Pager #4
Comments
|
Hi, you can find the code at in workspaces/adapter/src/testing/test.ts is the main function wich logs directly and works without hickups. the prettier doesn't like the code at the moment, I'll have to correct that before a PR ofcourse. Oh and congrats for reaching JHipster 8.0.0! |
I think we can simplify the implementation.
This is a conflicter only feature, we should try to don’t change others projects. |
This is what I have in mind: class ScrollableAdapter extends TerminalAdapter {
let content;
write(newContent) {
content = content + newContent;
}
async show() {
const scroll = new Scrollable({ content }).print();
console.log('Up [↑] and down [↓] arrow keys to scroll. [Q] to quit');
emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
return new Promise((resolve, reject) => {
const keyPressListener = (str, key) => {
if (key.name == 'up') {
scroll.scroll(-1).print();
process.stdout.cursorTo(0, 15);
}
if (key.name == 'down') {
scroll.scroll(1).print();
process.stdout.cursorTo(0, 15);
}
if (key.name == 'q') {
process.stdin.removeListener('keypress', keyPressListener);
// Cleanup stdin
resolve();
}
}
process.stdin.on('keypress', keyPressListener);
}
});
} |
|
Hi there,
like I said in
jhipster/generator-jhipster#24026
I gave it a try and eventually come up with something :)
I changed log.colored so that it first tries to spawn the system pager via another util , falling back if this should fail to log.write like it was before.
Now the problem is however, that Inquirer's prompt module seems to interfere somehow with stdin. E.g. in "less", I have to enter line by line down to the bottom before stdin is handed over to the spawned process and less accepts commands. what ever I type in between will be visible right above the next prompt. This happens when i pipe the contents via stdin and also if I dump it into a temp file beforehand and call less with that file.
Do you know a possibility how I somehow can destroy the prompt module and its UI when we received the answer and then recreate it after we return to conflicter._ask or to adapter.prompt the next time? Maybe that gets it out of the way and releasing stdin.
When I push 20k log lines (ca. 900k) into the logger directly via a test main, it immediately gives control, so thats why I suspect the prompt module.
A btw I was able to npm link @yeoman/adapter and /conflicter in my JHipster test project so after npm run build in one of those the changes were available for the next generator run.
Best
Martin
PS: I think async grew me some more gray hair :D
The text was updated successfully, but these errors were encountered: