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

libnpmexec: allow custom stdio option value. #6976

Open
wants to merge 3 commits into
base: latest
Choose a base branch
from

Conversation

mshima
Copy link

@mshima mshima commented Nov 8, 2023

libnpmexec forces 'inherit' value in stdio option.
Others stdio values are required for non interactive usage.

References

@mshima mshima requested a review from a team as a code owner November 8, 2023 14:55
@mshima mshima changed the title allow custom stdio option value. libnpmexec: allow custom stdio option value. Nov 8, 2023
@@ -31,7 +32,9 @@ const run = async ({
},
}

npmlog.disableProgress()
if (stdio === 'inherit') {
npmlog.disableProgress()
Copy link
Member

Choose a reason for hiding this comment

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

This is done so that the output from npm doesn't interlace with the output of your script. We always want to disable progress bars during exec.

@wraithgar
Copy link
Member

This will need a test

@mshima mshima marked this pull request as draft November 8, 2023 21:03
@mshima mshima marked this pull request as ready for review November 8, 2023 21:11
scriptShell,
})
} finally {
npmlog.enableProgress()
if (stdio === 'inherit') {
Copy link
Member

Choose a reason for hiding this comment

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

this one needs to be removed also

Copy link
Author

Choose a reason for hiding this comment

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

The idea is to make the libnpmexec don’t output npm logs.
npm log output is interlacing with the output of the application executing libnpmexec.
Just passing the stdio value through is not enough.

Copy link
Member

Choose a reason for hiding this comment

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

This isn't npm log output, this is progress bars specifically.

To suppress all logging we need npmlog.pause and npmlog.resume, but these should be independent of enabling/disabling progress.

Copy link
Author

Choose a reason for hiding this comment

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

I don't want to install npmlog directly to pause it.
What about a flag to ignore npmlog?

Copy link
Member

Choose a reason for hiding this comment

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

You already have it

const npmlog = require('npmlog')

Copy link
Author

Choose a reason for hiding this comment

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

I mean, I have ora as progress bar.
npmlog and ora are mangling the output.
I need to install and import npmlog in my project to pause the npmlog.
And that does not guarantee that the npmlog is muted due to hoisting.

@wraithgar
Copy link
Member

Looks good other than that rogue if statement

@wraithgar wraithgar self-assigned this Nov 9, 2023
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.

None yet

2 participants