pnp/cli-microsoft365

correct how we import `chalk` in cli.ts

Closed this issue · 0 comments

here we made a small mistake
3b7cd6f#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.