Function copySync

  • Copy a file or directory. The directory can have contents.

    Parameters

    • src: string

      Note that if src is a directory it will copy everything inside of this directory, not the entire directory itself (see issue #537).

    • dest: string

      Note that if src is a file, dest cannot be a directory (see issue #323).

    • Optional options: CopyOptionsSync

    Returns void

    Example

    import * as fs from 'fs-extra'

    // copy file
    fs.copySync('/tmp/myfile', '/tmp/mynewfile')

    // copy directory, even if it has subdirectories or files
    fs.copySync('/tmp/mydir', '/tmp/mynewdir')

    // Using filter function
    fs.copySync('/tmp/mydir', '/tmp/mynewdir', {
    filter(src, dest) {
    // your logic here
    // it will be copied if return true
    }
    })

Generated using TypeDoc