Variable: ensureSymlink()
const
ensureSymlink: {(src
,dest
,type?
):Promise
<void
>; (src
,dest
,callback
):void
; (src
,dest
,type
,callback
):void
; } =fs.ensureSymlink
Defined in: packages/node/src/fs.ts:8
Call Signature
(
src
,dest
,type?
):Promise
<void
>
Ensures that the symlink exists. If the directory structure does not exist, it is created.
Parameters
src
string
dest
string
type?
Type
It is only available on Windows and ignored on other platforms.
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.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()
Call Signature
(
src
,dest
,callback
):void
Ensures that the symlink exists. If the directory structure does not exist, it is created.
Parameters
src
string
dest
string
callback
NoParamCallback
Returns
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.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()
Call Signature
(
src
,dest
,type
,callback
):void
Ensures that the symlink exists. If the directory structure does not exist, it is created.
Parameters
src
string
dest
string
type
Type
It is only available on Windows and ignored on other platforms.
callback
NoParamCallback
Returns
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.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()