feat(analyze): add spinner for analysis phases#244
Conversation
|
| 📦 Package | 📋 Versions |
|---|---|
| eslint-visitor-keys | 2 versions
|
| @humanwhocodes/retry | 2 versions
|
| ignore | 2 versions
|
💡 To find out what depends on a specific package, run: npm ls example-package
commit: |
| await runPlugins(context, plugins); | ||
| } | ||
|
|
||
| async function finalizeReport(context: AnalysisContext) { |
There was a problem hiding this comment.
you're not gaining much by extracting this. the function definition and call sites are about as many LoC as these two statements
| if (res.stats) { | ||
| updateStats(context.stats, res.stats, seenExtra); | ||
| } | ||
| await runPlugin(context, plugin, seenExtra); |
There was a problem hiding this comment.
nothing changed here right? other than it being extracted into a single-use function
probably unnecessary?
There was a problem hiding this comment.
my initial thought was to encapsulate for readability purposes, but i think that you're right. it might be unnecessary. gonna fix this
| manifest?: string[]; | ||
| src?: string[]; | ||
| categories?: ParsedCategories; | ||
| phased?: PhasedRunner; |
There was a problem hiding this comment.
this is leaking internal implementation detail into the public options.
tbh im not sure we need a concept of a "runner" at all. that part may be overengineered. ill have a think and come back to it
| run: () => Promise<void>; | ||
| } | ||
|
|
||
| export type PhasedRunner = (phases: ReportPhase[]) => Promise<void>; |
There was a problem hiding this comment.
i think this is whats not sitting right with me. it seems over-engineered that we need a concept of a "phased runner", phases, etc.
i would expect something much, much simpler:
options.interactive; // boolean, from Options
// elsewhere...
const trackProgress = (options, fn) => {
if (!options.interactive) {
return fn();
}
startSpinner();
const result = await fn();
stopSpinner();
return result;
};
// elsewhere again...
await trackProgress(options, async () => {
// do some stuff
});
adds step by step progress during analyze so long runs don’t look frozen.