All files / rusted-chromium/store exportStore.ts

85.71% Statements 12/14
50% Branches 3/6
100% Functions 1/1
85.71% Lines 12/14

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 21 22 233x 3x   3x 3x   3x 3x   3x 2x       2x 2x       2x 2x    
import { createReadStream } from 'node:fs'
import { join } from 'node:path'
 
import { LOCAL_STORE_FILE } from '../commons/constants'
import { NoLocalstoreError } from '../errors'
import type { IExportConfig } from '../interfaces/interfaces'
import { DebugMode, logger } from '../log/logger'
import { existsAndIsFile } from '../utils/file.utils'
 
export async function exportStore(config: IExportConfig, stdio: NodeJS.WriteStream): Promise<void> {
    Iif(config.debug) {
        logger.setDebugMode(DebugMode.DEBUG)
    }
 
    const filePath = config.path ?? join(__dirname, '..', LOCAL_STORE_FILE)
    Iif (!(await existsAndIsFile(filePath))) {
        throw new NoLocalstoreError(config.path)
    }
 
    const reader = createReadStream(filePath)
    reader.pipe(stdio)
}