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

feat(core): add options parameter to repl #12924

Merged

Conversation

othierry
Copy link
Contributor

@othierry othierry commented Dec 15, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

The nestjs/core/repl function that runs node:repl does not allow the consumers to provide node:repl's option (ReplOptions).

Issue Number: #12916

What is the new behavior?

This PR allows passing ReplOptions to the nestjs/core/repl function. Current implemented behavior will also override default options prompt / ignoreUndefined if they are provided. If required, I can change the PR to not override this default options.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

  • I don't know if a test for this is required or not (we are just adding a new paramter whose type is defined within node typings itself). If a test is expected for this, it would be nice to have an hint of exactly "what" to test for to avoid writing uncessary code/tests.

Enables passing node repl options parameter to nestjs/core/repl

fixes nestjs#12916
@coveralls
Copy link

Pull Request Test Coverage Report for Build 8e7cb4c5-2c2a-40ff-bd50-32f96d6b3646

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage remained the same at 92.258%

Files with Coverage Reduction New Missed Lines %
packages/core/repl/repl.ts 1 50.0%
Totals Coverage Status
Change from base Build a2138bee-e39e-445f-b2ab-320ae7840dc5: 0.0%
Covered Lines: 6697
Relevant Lines: 7259

💛 - Coveralls

@@ -21,6 +26,7 @@ export async function repl(module: Type | DynamicModule) {
const replServer = _repl.start({
prompt: clc.green('> '),
ignoreUndefined: true,
...replOptions,
Copy link
Member

Choose a reason for hiding this comment

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

so now users can change the prompt. That's good, to me

But I wonder if changing the ignoreUndefined will break the repl 🤔 I don't why we're using ignoreUndefined: true tbh

Copy link
Contributor Author

@othierry othierry Dec 15, 2023

Choose a reason for hiding this comment

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

I wondered the same thing. Not really sure why ignoreUndefined is set to true but there's probably a reason behind ?

That's how it behaves :

  • node repl
> undefined
undefined
  • nestjs repl
> undefined
>

It's actually weird haha.

If we can confirm this is required, I can move the replOptions spread at the begining but that would prevent users to change the promp. I clould also force ignoreUndefined: true but keep the rest of replOptions. (and make it clear for users in typing like : Omit<ReplOptions, 'ignoreUndefined'>)

wdyt ?

@kamilmysliwiec
Copy link
Member

lgtm

@kamilmysliwiec kamilmysliwiec merged commit 3ec1cbc into nestjs:master Dec 18, 2023
3 checks passed
@othierry othierry deleted the feat/add-repl-options-support branch December 18, 2023 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants