Skip to content

Commit

Permalink
feat: reset cache after initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
leegeunhyeok committed Oct 23, 2023
1 parent 383bc9d commit 1856495
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 1 addition & 4 deletions packages/cli/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import { logger } from './shared';
ReactNativeEsbuildBundler.setGlobalLogLevel(
options.verbose ? LogLevel.Trace : LogLevel.Info,
);

if (options['reset-cache']) {
await ReactNativeEsbuildBundler.resetCache();
}
self.shouldResetCache = options['reset-cache'];

switch (getCommand(argv)) {
case 'start':
Expand Down
7 changes: 7 additions & 0 deletions packages/core/lib/bundler/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ export class ReactNativeEsbuildBundler extends BundlerEventEmitter {
logger.warn('bundler already initialized');
return this;
}

// Initialize.
const spinner = ora({ discardStdin: false }).start(
'Bundler initializing...',
);
Expand All @@ -381,6 +383,11 @@ export class ReactNativeEsbuildBundler extends BundlerEventEmitter {
this.initialized = true;
spinner.stop();

// Post initialize.
if (self.shouldResetCache) {
await ReactNativeEsbuildBundler.resetCache();
}

return this;
}

Expand Down
2 changes: 2 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ declare global {
// core config
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- `BundlerConfig` in @react-native-esbuild/core.
_config: any;
// core
shouldResetCache?: boolean;
// logger
logEnabled: boolean;
logLevel: number;
Expand Down

2 comments on commit 1856495

@vercel
Copy link

@vercel vercel bot commented on 1856495 Oct 23, 2023

Choose a reason for hiding this comment

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

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage report

St.
Category Percentage Covered / Total
🔴 Statements 15.67% 354/2259
🔴 Branches 18.17% 137/754
🔴 Functions 10.9% 69/633
🔴 Lines 14.97% 311/2078

Test suite run success

83 tests passing in 10 suites.

Report generated by 🧪jest coverage report action from 1856495

Please sign in to comment.