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

Remove kleur #176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Remove kleur #176

wants to merge 1 commit into from

Conversation

fabnguess
Copy link

No description provided.

@fabnguess fabnguess force-pushed the remove_kleur branch 2 times, most recently from 04220e7 to 479978a Compare January 2, 2025 22:14
@PierreDemailly
Copy link
Member

We need to add export type { Color } from "./colorTypes.js"; in index.ts otherwise Color is internal only.
Also, maybe types/color.ts would be better ? Or simply types.ts, this is the way we process types in our projects (for instance: https://github.com/NodeSecure/scanner/blob/master/workspaces/scanner/src/types.ts)

@PierreDemailly PierreDemailly requested a review from fraxken January 3, 2025 11:23
Comment on lines -77 to 86
if (color === null) {
this.#color = (str: string) => str;
}
else {
this.#color = color in kleur ? kleur[color] : kleur.white;

const colors = Array.isArray(color) ? color : [color];

if (colors.every((color) => kAvailableColors.has(color)) === false) {
throw new Error("Invalid color given");
}
Copy link
Member

Choose a reason for hiding this comment

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

We removed the assignment to colors property so nothing work as expected

@PierreDemailly
Copy link
Member

Hi @fabnguess, ping in case you forgot there is a change needed here 😋 (this.#color is never assigned)

@fabnguess
Copy link
Author

Hi @PierreDemailly ,

I'm having some difficulty with my unit tests. Currently I'm trying to mock the display of the spinner frames to verify that the color is correctly applied. Here is the code I wrote. Could you tell me if it is correct and give me advice on how to improve it?

describe("spinner frame rendering", () => {
  it("should apply the correct color to the spinner frame", async () => {
    const spin = new Spinner({ verbose: false });

    spin.start("Loading...");

    const originalWrite = process.stdout.write;
    let output = "";
    process.stdout.write = (chunk) => {
      output += chunk;
      return true;
    };

    process.stdout.write = originalWrite;

   await once(spin, "start", { signal: AbortSignal.timeout(100) });

    const ESC = "\x1b";
    assert.match(output, new RegExp(`${ESC}\\[34m`));
  });
});

@PierreDemailly
Copy link
Member

Since stream is public, maybe we can set a mock ?

public stream: TTY.WriteStream = process.stdout;

this.stream.write(line);

@fabnguess
Copy link
Author

Okay, I'll work on that.

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