-
Notifications
You must be signed in to change notification settings - Fork 27
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
Integrate promirepl #49
Comments
@danielgtaylor how could we add a function to receive the evaluated value before returning the evaluated value to the shell? Ideally, we would just check if it's a promise and if it's a promise we would "await" on it, I'm sure it wouldn't be complicated, it's just about "spoofing" the eval method? |
That's how i worked it out: nesh.start options, ( error, repl ) ->
# report error
if error then console.log nesh.log.error error
old_eval = repl.eval
repl.eval = ( input, context, filename, callback ) ->
old_eval input, context, filename, ( error, value ) ->
if error then return callback error
if value instanceof Promise
try
result = await value
return callback null, result
catch error
return callback error
callback error, value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/building5/node-promirepl ❤️
I'll probably write a PR for this, since it's just mostly
copyingforking their code, and can be completely optional via the.promise
togglabilityThe text was updated successfully, but these errors were encountered: