Function ensureLink

  • Ensures that the link exists. If the directory structure does not exist, it is created.

    Parameters

    • src: string
    • dest: string

    Returns Promise<void>

    Example

    import * as fs from 'fs-extra'

    const srcPath = '/tmp/file.txt'
    const destPath = '/tmp/this/path/does/not/exist/file.txt'

    // With a callback:
    fs.ensureLink(srcPath, destPath, err => {
    console.log(err) // => null
    // link has now been created, including the directory it is to be placed in
    })

    // With Promises:
    fs.ensureLink(srcPath, destPath)
    .then(() => {
    console.log('success!')
    })
    .catch(err => {
    console.error(err)
    })

    // With async/await:
    async function asyncAwait () {
    try {
    await fs.ensureLink(srcPath, destPath)
    console.log('success!')
    } catch (err) {
    console.error(err)
    }
    }

    asyncAwait()
  • Parameters

    Returns void

Generated using TypeDoc