import { Target } from "./../../common/Objects/ActionRequest" ; import { ConversionResult } from "./../../common/Objects/ConversionResult" ; import { CSVRow } from "./../../common/Objects/CSVRow" ; import { CSVConf , HTAccessConf } from "./../../culturize.conf" ; import { ApacheConverter } from "./../Converter/ApacheConverter" ; import { NginxConverter } from "./../Converter/NginxConverter" ; import { createArrayFromCSV } from "./../Parser/Parser" ; param { string } filepath param { Target } target param { string } subdir returns export async function convertCSVtoWebConfig ( filepath , target , subdir ) { let numAccepted = 0 ; let numRejected = 0 ; try { const rows = await createArrayFromCSV ( filepath , ( row ) => { numAccepted ++ ; } , ( row ) => { numRejected ++ ; } ) ; if ( target === Target . apache ) { const creator = new ApacheConverter ( rows ) ; return new ConversionResult ( creator . makeHTAccessFile ( ) , numRejected , numAccepted , rows ) ; } else { const creator = new NginxConverter ( rows , subdir ) ; return new ConversionResult ( creator . makeNginxConfFile ( ) , numRejected , numAccepted , rows ) ; } } catch ( error ) { throw error ; } }