Skip to content

Fix minor issue with CLI.md automatic doc generation #201

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

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

0xalexbel
Copy link
Contributor

  • Sometimes (randomly) the CLI.md Command paragraph is not correct. After a bit of inquiry, I finally realised that the console.log(JSON.stringify(...)) call in finalizeCli was incomplete, the output string was truncated thus resulting in a later JSON parse error. This was mainly due to console.log not having enough time to flush before process.exit(0)

  • Little improvement, fix init and info entries.

Hope it helps!

0xalexbel added 2 commits May 10, 2023 15:36
- [init] -> [iexec init]
- [info] -> [iexec info]
Problem is due to the fact that 'init' and 'info' cmds are not located
in a dedicated js file.
- give console.log() a chance to flush the output string.
@PierreJeanjacquot
Copy link
Member

Hi, thank you for catching this, can you confirm this issue occurs on Windows as stated in node doc https://nodejs.org/api/process.html#a-note-on-process-io ?

@0xalexbel
Copy link
Contributor Author

0xalexbel commented May 17, 2023

Hi Pierre, unfortunately I am not able to run the sdk on Windows (I'm a Mac user). Before submitting the PR, I carefully checked the same nodejs doc link, and curiously:

  • GENERATE_DOC=1 node src/cli/cmd/iexec-app.js | jq . : works fine (POSIX + pipe)
  • npm run generate-cli-doc : fails (the app cmd paragraph is empty, the JSON was truncated)

I was not a great fan of the sleep solution I submitted to you, it looks more like a quick and dirty patch to me. One possible alternative could be:

In function

export const finalizeCli = (cli) => {

If : process.exit(0) is replaced by a return statement:

  • npm run generate-cli-doc : succeeds (the app cmd paragraph is OK)

This may let node finish its internal stuff before exiting (including a proper buffer flush). Obviously, this solution also depends on what's going on after the finalizeCli function has exited (didn't checked).

Hope it helps!

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.

2 participants