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

fix: Force colors to not be stripped off when piping child process stdout #677

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

Amplifiyer
Copy link
Contributor

Description of changes: Piping the child process output by default strips off the color for consuming streams. This is a workaround to preserve the color being piped to parent process. See Marak/colors.js#127 (comment)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

changeset-bot bot commented Nov 16, 2023

🦋 Changeset detected

Latest commit: bb7f2bd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@aws-amplify/backend-deployer Patch
@aws-amplify/sandbox Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 173 to 176
// Piping the output by default strips off the color. This is a workaround to
// preserve the color being piped to parent process. Later we reset it to whatever it was before.
const oldForceColorValue = process.env['FORCE_COLOR'];
process.env['FORCE_COLOR'] = '1';
Copy link
Member

Choose a reason for hiding this comment

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

Can we clone process.env, append this to a copy and pass to child process ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, only setting in the child process now.

@@ -184,6 +189,7 @@ export class CDKDeployer implements BackendDeployer {

try {
await childProcess;
process.env['FORCE_COLOR'] = oldForceColorValue;
Copy link
Member

Choose a reason for hiding this comment

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

this should be in finally block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no longer needed.

@Amplifiyer Amplifiyer merged commit ad4ff92 into aws-amplify:main Nov 16, 2023
20 checks passed
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.

3 participants