Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
fix(cdnCache): make clear cache message generic (#1248)
Browse files Browse the repository at this point in the history
Co-authored-by: Jamie King <jamie.king@aexp.com>
Co-authored-by: Danny <djpepin1299@gmail.com>
  • Loading branch information
3 people authored Jan 23, 2024
1 parent 26a7740 commit cac2e81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 12 additions & 0 deletions __tests__/server/utils/cdnCache.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ describe('cacheUtils', () => {
expect(logSpy).not.toHaveBeenCalled();
expect(errorSpy).toHaveBeenCalledWith('There was error checking file stat', expectedError);
});

it('showCacheInfo should show file to delete', async () => {
const mockStats = {
size: 1024 * 1024 * 5, // 5 MB
};
fsPromises.stat.mockResolvedValue(mockStats);

await showCacheInfo();

expect(logSpy).toHaveBeenCalledWith('To clear the cache, please delete this file:');
expect(logSpy).toHaveBeenCalledWith(' ~/.one-app/.one-app-module-cache');
});
});

describe('setupCacheFile', () => {
Expand Down
5 changes: 2 additions & 3 deletions src/server/utils/cdnCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import chalk from 'chalk';

export const getUserHomeDirectory = () => process.env.HOME || process.env.USERPROFILE;
export const cacheFileName = '.one-app-module-cache';
export const moduleCacheFileName = '.one-app-module-map-cache';
export const oneAppDirectoryName = '.one-app';
export const oneAppDirectoryPath = path.join(getUserHomeDirectory(), oneAppDirectoryName);
export const oneAppModuleCachePath = path.join(oneAppDirectoryPath, cacheFileName);
Expand All @@ -33,8 +32,8 @@ export const showCacheInfo = async () => {
console.log(chalk.bold.cyanBright(separator));
console.log(chalk.bold.cyanBright('CACHE INFORMATION'));
console.log(message);
console.log('To delete cache, please run');
console.log(` ${chalk.bold.cyanBright(' rm ', oneAppModuleCachePath)}`);
console.log('To clear the cache, please delete this file:');
console.log(` ${chalk.bold.cyanBright(path.join('~', oneAppDirectoryName, cacheFileName))}`);
console.log(chalk.bold.cyanBright(separator));
} catch (error) {
console.error('There was error checking file stat', error);
Expand Down

0 comments on commit cac2e81

Please sign in to comment.