-
-
Notifications
You must be signed in to change notification settings - Fork 12
Update to read v3 #150
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
Update to read v3 #150
Conversation
51b7330
to
6981ce7
Compare
Read v4 declares a dependency on Node v18 at least and the bundled Node version is v16.0.0 still. The modifications aren't big but that upgrade would be the way even further. Other than that, this package didn't change a lot. It's supposed to "just work" if one exports the `read` function appropriately (not as a "default" import), with an async interface that we pretty much already had because of the promptX kind of methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
This removes error handling. const { read } = require('read')
// or with ESM: import { read } from 'read'
try {
const result = await read(options)
} catch (er) {
console.error(er)
} With Per StackOverflow (https://stackoverflow.com/questions/42453683/how-to-reject-in-async-await-syntax), we can let answer;
try {
answer = await read({prompt: 'Would you like to install these updates? (yes)', edit: true});
} catch (error) {
throw(error);
} Or add a let answer = await read({prompt: 'Would you like to install these updates? (yes)', edit: true}).catch(error => throw(error)); Something like that. Perhaps I can investigate the right way to restore error handing myself, but you are also free to attempt it. |
My suggestion above was discussed on Discord, and it was pointed out to behave equivalently with or without try/catch. I can confirm that is true in my own testing now. There is minimal logging of the error in this situation regardless, it looks like this if throwing just before % ./bin/ppm upgrade deedeeg-new-package-1
Package Updates Available (1)
└── deedeeg-new-package-1 0.0.1 -> 0.0.9
some error string (this is red) Since it's the same as before this PR, there is no issue. Thanks for bearing with me while I test things locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks reasonable, moreso after discussion on Discord. I confirmed it behaves equivalently, and it is functional (upgrading my package on the CLI works) just the same as master
branch.
So, Approved from me as well. Merging. Thanks for the dependency bumps lately.
Read v4 declares a dependency on Node v18 at least and the bundled Node version is v16.0.0 still. The modifications aren't big but that upgrade would be the way even further. Other than that, this package didn't change a lot. It's supposed to "just work" if one exports the
read
function appropriately (not as a "default" import), with an async interface that we pretty much already had because of the promptX kind of methods.