Variable: move()
constmove: {(src,dest,options?):Promise<void>; (src,dest,callback):void; (src,dest,options,callback):void; } =fs.move
Defined in: packages/node/src/fs.ts:11
Call Signature
(
src,dest,options?):Promise<void>
Moves a file or directory, even across devices.
Parameters
src
string
dest
string
Note: When src is a file, dest must be a file and when src is a directory, dest must be a directory.
options?
MoveOptions
Returns
Promise<void>
Example
import * as fs from 'fs-extra'
const src = '/tmp/file.txt'
const dest = '/tmp/this/path/does/not/exist/file.txt'
// With a callback:
fs.move(src, dest, err => {
if (err) return console.error(err)
console.log('success!')
})
// With Promises:
fs.move(src, dest)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
// With async/await:
async function asyncAwait () {
try {
await fs.move(src, dest)
console.log('success!')
} catch (err) {
console.error(err)
}
}
asyncAwait()
// Using `overwrite` option
fs.move('/tmp/somedir', '/tmp/may/already/exist/somedir', { overwrite: true }, err => {
if (err) return console.error(err)
console.log('success!')
})Call Signature
(
src,dest,callback):void
Moves a file or directory, even across devices.
Parameters
src
string
dest
string
Note: When src is a file, dest must be a file and when src is a directory, dest must be a directory.
callback
NoParamCallbackWithUndefined
Returns
void
Example
import * as fs from 'fs-extra'
const src = '/tmp/file.txt'
const dest = '/tmp/this/path/does/not/exist/file.txt'
// With a callback:
fs.move(src, dest, err => {
if (err) return console.error(err)
console.log('success!')
})
// With Promises:
fs.move(src, dest)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
// With async/await:
async function asyncAwait () {
try {
await fs.move(src, dest)
console.log('success!')
} catch (err) {
console.error(err)
}
}
asyncAwait()
// Using `overwrite` option
fs.move('/tmp/somedir', '/tmp/may/already/exist/somedir', { overwrite: true }, err => {
if (err) return console.error(err)
console.log('success!')
})Call Signature
(
src,dest,options,callback):void
Moves a file or directory, even across devices.
Parameters
src
string
dest
string
Note: When src is a file, dest must be a file and when src is a directory, dest must be a directory.
options
MoveOptions
callback
NoParamCallbackWithUndefined
Returns
void
Example
import * as fs from 'fs-extra'
const src = '/tmp/file.txt'
const dest = '/tmp/this/path/does/not/exist/file.txt'
// With a callback:
fs.move(src, dest, err => {
if (err) return console.error(err)
console.log('success!')
})
// With Promises:
fs.move(src, dest)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
// With async/await:
async function asyncAwait () {
try {
await fs.move(src, dest)
console.log('success!')
} catch (err) {
console.error(err)
}
}
asyncAwait()
// Using `overwrite` option
fs.move('/tmp/somedir', '/tmp/may/already/exist/somedir', { overwrite: true }, err => {
if (err) return console.error(err)
console.log('success!')
})