All files / rusted-chromium rusted.ts

100% Statements 23/23
100% Branches 7/7
100% Functions 1/1
100% Lines 23/23

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 23 24 25 26 27 28 29 30 31 321x 1x   1x 1x 1x 1x 1x   1x 5x   5x 1x 1x 1x     5x 1x 1x 4x 2x 2x 2x 1x 1x   1x      
import { readConfig } from './config/config'
import { downloadChromium } from './download/download'
import type { IChromeConfig, IStoreConfig, IExportConfig } from './interfaces/interfaces'
import { logger } from './log/logger'
import { progress } from './log/progress'
import { spinner } from './log/spinner'
import { exportStore } from './store/exportStore'
import { importAndMergeLocalstore } from './store/importStore'
 
export async function rusted(args: string[], platform: NodeJS.Platform): Promise<void> {
    const configWrapper = readConfig(args, platform)
 
    if (configWrapper.config.quiet) {
        spinner.silent()
        logger.silent()
        progress.silent()
    }
 
    if (configWrapper.action === 'importStore') {
        const config: IStoreConfig = configWrapper.config
        await importAndMergeLocalstore(config)
    } else if (configWrapper.action === 'loadChrome') {
        const config: IChromeConfig = configWrapper.config
        await downloadChromium(config)
    } else if (configWrapper.action === 'exportStore') {
        const config: IExportConfig = configWrapper.config
        exportStore(config, process.stdout)
    } else {
        logger.error(`Failed to read config: ${JSON.stringify(configWrapper)}`)
    }
}