Skip to content

Fix Node.js without ICU support - #1144

Merged
sindresorhus merged 1 commit into
mainfrom
char-escape
Aug 14, 2024
Merged

sindresorhus merged 1 commit into
mainfrom
char-escape

Conversation

@ehmicky

@ehmicky ehmicky commented Aug 13, 2024 •

Copy link
Copy Markdown
Collaborator

Fixes #1143.

This PR does not add any documentation because this is a very tiny edge case that almost nobody will encounter:

  • Running Node.js without ICU support requires building your own Node.js binary. No pre-built binary without ICU support seems to be available.
  • Then, the user would need to use very special characters in the command, such as isolated surrogate characters or reserve Unicode codepoints (which is quite unlikely) to notice any difference.
  • Even then, the only difference would only be that those special characters would be printed as is on the terminal (when using result.escapedCommand) instead of being represented as a backslash sequence \u..., which is not a big problem.

}

static isMocked = true;
};

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I cannot find a simple way to run tests using Node without ICU support. So this mimics it for our purpose.

};

// Execa computes the RegExp when first loaded, so we must delay this import
await import('./escape.js');

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We could mock/unmock RegExp directly in escape.js, and run each test twice. But then each test would need to be serial. Also it makes the test file a little complex (this was my first approach). Using a separate test file that imports the other one results in less code.

@ehmicky ehmicky mentioned this pull request Aug 13, 2024
@sindresorhus
sindresorhus merged commit 074ea4a into main Aug 14, 2024
@sindresorhus
sindresorhus deleted the char-escape branch August 14, 2024 12:54
@Uzlopak

Uzlopak commented Aug 14, 2024

Copy link
Copy Markdown

When will it be released? :)

@ehmicky

ehmicky commented Aug 14, 2024 •

Copy link
Copy Markdown
Collaborator Author

This has now been released in 9.3.1. Thanks again for your help.

Is this working?

@Uzlopak

Uzlopak commented Aug 14, 2024

Copy link
Copy Markdown

Thank you. Yes :). Great Success.

PS:
https://x.com/uzlopak_js/status/1823796028182814975

@ehmicky

ehmicky commented Aug 14, 2024

Copy link
Copy Markdown
Collaborator Author

Thanks for the shout out @Uzlopak, that's very kind! 🙏

@Uzlopak

Uzlopak commented Aug 14, 2024

Copy link
Copy Markdown

Unfortunately, you are not on twitter, or else I would have linked you.

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.

Intl needed for v. 9

3 participants