1const {promisify} = require('util');
2const fs = require('fs');
3const {join} = require('path');
4const mv = promisify(fs.rename);
5
6const moveThem = async () => {
7 // Move file ./bar/foo.js to ./baz/qux.js
8 const original = join(__dirname, 'bar/foo.js');
9 const target = join(__dirname, 'baz/qux.js');
10 await mv(original, target);
11}
12
13moveThem();
14
1var fs = require('fs-extra')
2
3fs.move('/tmp/somefile', '/tmp/does/not/exist/yet/somefile', function (err) {
4 if (err) return console.error(err)
5 console.log("success!")
6})
7