Skip to content

Commit

Permalink
remove data from type
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaiwat10 committed Sep 19, 2024
1 parent 6e4001d commit 7c4d96f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/fuels/src/cli/utils/fuelsVersionCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'path';
export const FUELS_VERSION_CACHE_FILE = path.join(__dirname, '.fuels-cache.json');

export type FuelsVersionCache = {
data: { version: string } | null;
version: string;
timestamp: number;
};

Expand Down
8 changes: 2 additions & 6 deletions packages/fuels/src/cli/utils/getLatestFuelsVersion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ describe('getLatestFuelsVersion', () => {

it('should return cached version if it exists', async () => {
const cache = {
data: {
version: '1.0.0',
},
version: '1.0.0',
timestamp: Date.now(),
};
vi.spyOn(cacheMod, 'checkAndLoadCache').mockReturnValue(cache);
Expand All @@ -43,9 +41,7 @@ describe('getLatestFuelsVersion', () => {
expect(fetchSpy).toHaveBeenCalled();
expect(version).toEqual('1.0.0');
expect(saveCacheSpy).toHaveBeenCalledWith({
data: {
version: '1.0.0',
},
version: '1.0.0',
timestamp: expect.any(Number),
});
});
Expand Down
8 changes: 3 additions & 5 deletions packages/fuels/src/cli/utils/getLatestFuelsVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export const getLatestFuelsVersion = async (): Promise<string | undefined> => {
const now = Date.now();

const cache = checkAndLoadCache();
if (cache && cache.data) {
return cache.data.version;
if (cache) {
return cache.version;
}

const data: { version: string } | null = await Promise.race([
Expand All @@ -22,9 +22,7 @@ export const getLatestFuelsVersion = async (): Promise<string | undefined> => {
const version = data.version as string;

saveToCache({
data: {
version,
},
version,
timestamp: now,
});

Expand Down

0 comments on commit 7c4d96f

Please sign in to comment.