import { extendedPingOptions , commandBuilder , pingResponse } from './types' ; import builderFactory from './builder/builder' ; import * as os from 'os' ; import Logger from './log' ; import execute from './ping' ; import parserFactory from './parser/parserFactory' ; const ping = async ( ipAddress , pingOptions ? ) => { let logger ; logger = new Logger ( pingOptions ?. logFilePath || 'log.txt' , pingOptions ?. logToFile || false ) ; try { const platform = os . platform ( ) ; const builtCommand = builderFactory ( ipAddress , platform , pingOptions ) ; logger . writeToLogFile ( JSON . stringify ( builtCommand ) ) ; const pingOutput = await execute ( builtCommand ) ; const parsedOutput = parserFactory ( platform , pingOutput , pingOptions ) ; logger . writeToLogFile ( JSON . stringify ( parsedOutput . output ) ) ; return parsedOutput ; } catch ( error ) { logger . writeToLogFile ( error ) ; throw error ; } } ; export default ping ; module . exports = ping ; module . exports . default = ping ; export { extendedPingOptions , pingOptions , pingResponse } from './types' ;