cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

correct how we import `chalk` in cli.ts

Open Adam-it opened this issue 1 year ago • 0 comments

here we made a small mistake https://github.com/pnp/cli-microsoft365/commit/3b7cd6f617bb737fac9201196d3b80d755933b02#diff-25768f5853544984f9e0188641fe6d70f0e5d5245c9317d80be7d3d32a71dd44

We should not import chalk at the top globally but rather inline only when needed. We already have it done like this in other places, for example:

const chalk = (await import('chalk')).default;
await logger.logToStderr(chalk.green('DONE'));

We only need chalk when we write colors, ie. log errors. Since we typically don't do it, we don't load chalk by default, which improves performance of the CLI.

Adam-it avatar May 05 '24 23:05 Adam-it