Skip to content
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

Print run-js return value #71

Merged
merged 5 commits into from
Sep 2, 2023
Merged

Print run-js return value #71

merged 5 commits into from
Sep 2, 2023

Conversation

Aylur
Copy link
Owner

@Aylur Aylur commented Aug 30, 2023

if a single javascript statement (meaning it doesn't have a semicolon) is passed to --run-js it will print it to stdout
if the passed argument has a semicolon, whatever this passed function returns will be printed to stdout

# prints current date
ags --run-js "new Date()"
ags --run-js "const date = new Date(); return date;"

# prints undefined
ags --run-js "new Date();"

this PR also introduces the --run-promise flag which allows running async functions and print with resolve or reject

ags --run-promise "ags.Utils.timeout(1000, () => resolve('a second later'))"

if the argument of run-js is a
* single line expression, print it to stdout
* multiline function, then the function has to call resolve or reject
@Aylur Aylur merged commit da97971 into main Sep 2, 2023
2 checks passed
@Aylur Aylur deleted the feature/client-process branch September 2, 2023 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant