All files / rusted-chromium/store storeNegativeHit.ts

100% Statements 10/10
100% Branches 1/1
100% Functions 1/1
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 214x 4x     4x     4x   4x   4x 5x   5x 5x   5x      
import { writeFile } from 'node:fs/promises'
import { join as pathJoin } from 'node:path'
 
import type { ComparableVersion } from '../commons/ComparableVersion'
import { LOCAL_STORE_FILE } from '../commons/constants'
import type { OS } from '../interfaces/os.interfaces'
import type { Arch } from '../interfaces/store.interfaces'
import { loadStore } from './loadStore'
 
const STORE_FILE = pathJoin(__dirname, '..', LOCAL_STORE_FILE)
 
export async function storeNegativeHit(version: ComparableVersion, os: OS, arch: Arch): Promise<void> {
    const currentStore = await loadStore()
    
    if (!currentStore.has(os, arch, version)) {
        currentStore.add(os, arch, version)
 
        await writeFile(STORE_FILE, currentStore.toMinimalFormattedString())
    }
}