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

watch: add CLI flag to preserve output #45717

Merged
merged 12 commits into from
Dec 11, 2022

Conversation

debadree25
Copy link
Member

Added a --preserve-output flag to watch mode
Fixes: #45713

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Dec 2, 2022
Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is clearing the terminal really a good default choice? Doesn't that potentially take away error messages etc., depending on the terminal host? What if stdout is not a TTY?

src/node_options.cc Outdated Show resolved Hide resolved
@debadree25
Copy link
Member Author

Is clearing the terminal really a good default choice? Doesn't that potentially take away error messages etc., depending on the terminal host? What if stdout is not a TTY?

I guess you are right it could be inconvenient to have to add a flag in order to preserve the output, if suggested i could change the logic to preserving the output by default

@debadree25 debadree25 changed the title [Draft] lib,src: add flag to preserve outputs lib,src: add flag to preserve outputs Dec 2, 2022
@debadree25 debadree25 marked this pull request as ready for review December 2, 2022 19:50
@debadree25
Copy link
Member Author

Have added the relevant tests and refactored the option flag, I believe its ready for a review

Thank You!

@MoLow
Copy link
Member

MoLow commented Dec 3, 2022

No strong opinion regarding what the default to be, but I do think we should support clearing

@debadree25
Copy link
Member Author

@MoLow @tniessen any further thoughts on how we could progress on this? i guess making the default to not clear the screen could be a good idea, can refactor the code accordingly

@tniessen
Copy link
Member

i guess making the default to not clear the screen could be a good idea, can refactor the code accordingly

I don't use watch mode and I am not familiar with the current implementation. cc'ing those who approved #44366: @aduh95 @benjamingr

Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to have an option for this, I think changing the default can be done in a separate PR – this PR also adds --no-watch-preserve-output flag so if we want to switch the default it's already a step in the right direction.
Two nits:

doc/api/cli.md Outdated Show resolved Hide resolved
lib/internal/main/watch_mode.js Outdated Show resolved Hide resolved
@debadree25
Copy link
Member Author

I think it makes sense to have an option for this, I think changing the default can be done in a separate PR – this PR also adds --no-watch-preserve-output flag so if we want to switch the default it's already a step in the right direction. Two nits:

understood so if changing the default is needed we can just update the option name in a separate PR?

Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to change the first commit message to use watch subsystem instead of lib,src? I suggest something like watch: add CLI flag to preserve output. If not it's OK it can be done by whoever lands this PR, or I can do it if you prefer.

doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
@aduh95
Copy link
Contributor

aduh95 commented Dec 11, 2022

understood so if changing the default is needed we can just update the option name in a separate PR?

Yes, we would need to update the docs, and change the value from false to true in src/node_options.h, and voilà.

@debadree25
Copy link
Member Author

Understood, rebasing the commit

debadree25 and others added 12 commits December 11, 2022 23:04
Added a --watch-preserve-output flag to watch mode
Fixes: nodejs#45713
Co-authored-by: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 11, 2022
@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 11, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 11, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/45717
✔  Done loading data for nodejs/node/pull/45717
----------------------------------- PR info ------------------------------------
Title      watch: add CLI flag to preserve output (#45717)
Author     Debadree Chatterjee  (@debadree25)
Branch     debadree25:ft/add-preserve-output-flag -> nodejs:main
Labels     c++, author ready, needs-ci, commit-queue-squash
Commits    12
 - watch: add CLI flag to preserve output
 - test: add test for preserve-output
 - lib,src: fixed linting issues
 - lib,src: refactor naming of flag
 - doc: add option to doc
 - doc: fix option ordering
 - test: remove unnecessary console
 - lib: store clear output in a const
 - doc: update content
 - lib: refactor writing output
 - doc: update content
 - doc: update content
Committers 1
 - Debadree Chatterjee 
PR-URL: https://github.com/nodejs/node/pull/45717
Fixes: https://github.com/nodejs/node/issues/45713
Reviewed-By: Antoine du Hamel 
Reviewed-By: Moshe Atlow 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/45717
Fixes: https://github.com/nodejs/node/issues/45713
Reviewed-By: Antoine du Hamel 
Reviewed-By: Moshe Atlow 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Fri, 02 Dec 2022 18:03:15 GMT
   ✔  Approvals: 2
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/45717#pullrequestreview-1212730014
   ✔  - Moshe Atlow (@MoLow): https://github.com/nodejs/node/pull/45717#pullrequestreview-1212754092
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-12-11T17:46:19Z: https://ci.nodejs.org/job/node-test-pull-request/48410/
- Querying data for job/node-test-pull-request/48410/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 45717
From https://github.com/nodejs/node
 * branch                  refs/pull/45717/merge -> FETCH_HEAD
✔  Fetched commits as 22dc987fde29..dafdb5827c39
--------------------------------------------------------------------------------
[main 23433fbbd4] watch: add CLI flag to preserve output
 Author: Debadree Chatterjee 
 Date: Fri Dec 2 23:26:43 2022 +0530
 3 files changed, 9 insertions(+), 3 deletions(-)
[main cb41045603] test: add test for preserve-output
 Author: Debadree Chatterjee 
 Date: Sat Dec 3 00:27:34 2022 +0530
 1 file changed, 26 insertions(+)
[main 7138359251] lib,src: fixed linting issues
 Author: Debadree Chatterjee 
 Date: Sat Dec 3 00:27:59 2022 +0530
 2 files changed, 5 insertions(+), 3 deletions(-)
[main 41fc6d8488] lib,src: refactor naming of flag
 Author: Debadree Chatterjee 
 Date: Sat Dec 3 01:02:40 2022 +0530
 4 files changed, 7 insertions(+), 7 deletions(-)
[main 6b6b34a473] doc: add option to doc
 Author: Debadree Chatterjee 
 Date: Sat Dec 3 01:02:59 2022 +0530
 1 file changed, 9 insertions(+)
[main d6020e08a1] doc: fix option ordering
 Author: Debadree Chatterjee 
 Date: Sat Dec 3 01:10:07 2022 +0530
 1 file changed, 1 insertion(+), 1 deletion(-)
[main 7f49b18f72] test: remove unnecessary console
 Author: Debadree Chatterjee 
 Date: Sat Dec 3 01:45:10 2022 +0530
 1 file changed, 1 deletion(-)
[main b16f74385c] lib: store clear output in a const
 Author: Debadree Chatterjee 
 Date: Sat Dec 3 23:14:55 2022 +0530
 1 file changed, 2 insertions(+), 1 deletion(-)
[main d52b3f463f] doc: update content
 Author: Debadree Chatterjee 
 Date: Sun Dec 11 22:44:53 2022 +0530
 1 file changed, 1 insertion(+), 1 deletion(-)
[main 56a8f68c6e] lib: refactor writing output
 Author: Debadree Chatterjee 
 Date: Sun Dec 11 22:45:42 2022 +0530
 1 file changed, 2 insertions(+), 4 deletions(-)
[main 0185245962] doc: update content
 Author: Debadree Chatterjee 
 Date: Sun Dec 11 23:00:25 2022 +0530
 1 file changed, 1 insertion(+), 1 deletion(-)
[main 00b1a164a5] doc: update content
 Author: Debadree Chatterjee 
 Date: Sun Dec 11 23:00:44 2022 +0530
 1 file changed, 1 insertion(+), 1 deletion(-)
   ✔  Patches applied
There are 12 commits in the PR. Attempting to fixup everything into first commit.
[main 885f461251] watch: add CLI flag to preserve output
 Author: Debadree Chatterjee 
 Date: Fri Dec 2 23:26:43 2022 +0530
 5 files changed, 43 insertions(+), 2 deletions(-)
   ✖  Git found no trailers in the original commit message, but 'Fixes: https://github.com/nodejs/node/issues/45713' is present and should be a trailer.
https://github.com/nodejs/node/actions/runs/3670813383

@nodejs-github-bot nodejs-github-bot added the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Dec 11, 2022
@aduh95 aduh95 merged commit 79a977a into nodejs:main Dec 11, 2022
@aduh95
Copy link
Contributor

aduh95 commented Dec 11, 2022

Landed in 79a977a, thanks for the contribution 🎉

@debadree25
Copy link
Member Author

Landed in 79a977a, thanks for the contribution 🎉

Thank you so much! thank you for your time too!

Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like adding these many flags to Node's core executable. I would prefer it if this was an option to the existing flags.

The actual changes lgtm

@tniessen
Copy link
Member

@benjamingr Agreed. Maybe an interface similar to python's -m would be helpful, where mode-specific options are only parsed after the mode has been selected. Especially for the test runner and for watch mode, this could be relevant.

ErickWendel pushed a commit to ErickWendel/node that referenced this pull request Dec 12, 2022
Fixes: nodejs#45713
PR-URL: nodejs#45717
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
targos pushed a commit that referenced this pull request Dec 12, 2022
Fixes: #45713
PR-URL: #45717
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
targos pushed a commit that referenced this pull request Dec 13, 2022
Fixes: #45713
PR-URL: #45717
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
Fixes: #45713
PR-URL: #45717
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
Fixes: #45713
PR-URL: #45717
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
Fixes: #45713
PR-URL: #45717
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams pushed a commit that referenced this pull request Jan 4, 2023
Fixes: #45713
PR-URL: #45717
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams pushed a commit that referenced this pull request Jan 5, 2023
Fixes: #45713
PR-URL: #45717
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
nodejs-github-bot pushed a commit that referenced this pull request Aug 16, 2024
PR-URL: #54328
Refs: #45717
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
RafaelGSS pushed a commit that referenced this pull request Aug 19, 2024
PR-URL: #54328
Refs: #45717
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
RafaelGSS pushed a commit that referenced this pull request Aug 21, 2024
PR-URL: #54328
Refs: #45717
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
targos pushed a commit that referenced this pull request Sep 21, 2024
PR-URL: #54328
Refs: #45717
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
targos pushed a commit that referenced this pull request Sep 26, 2024
PR-URL: #54328
Refs: #45717
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
targos pushed a commit that referenced this pull request Oct 2, 2024
PR-URL: #54328
Refs: #45717
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add flag to disable terminal clear in --watch mode
7 participants