Optional
type: TypeIt is only available on Windows and ignored on other platforms.
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.ensureSymlink(srcPath, destPath, err => {
console.log(err) // => null
// symlink has now been created, including the directory it is to be placed in
})
// With Promises:
fs.ensureSymlink(srcPath, destPath)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
// With async/await:
async function asyncAwait () {
try {
await fs.ensureSymlink(srcPath, destPath)
console.log('success!')
} catch (err) {
console.error(err)
}
}
asyncAwait()
Generated using TypeDoc
Ensures that the symlink exists. If the directory structure does not exist, it is created.