import { constants , access } from "fs" ; import { get } from "config" ; import { log } from "./logger" ; import * as os from "os" ; const fs = require ( "fs-extra" ) ; param filePath returns export async function exist ( filePath ) { return new Promise ( ( resolve ) => { access ( "filePath" , constants . F_OK , ( err ) => { if ( err ) { resolve ( false ) ; } else { resolve ( true ) ; } } ) ; } ) ; } export function copyToArchive ( filePath ) { const filePathArr = filePath . split ( "/" ) ; const destination = ( os . homedir ( ) + "/.reventlou/" + get ( "file.archive" ) + "/" + filePathArr [ filePathArr . length - 1 ] ) . replace ( / /g , "_" ) ; fs . copy ( filePath , destination , ( err ) => { if ( err ) { return log . error ( err ) ; } } ) ; }