JSFiddle - React, Tailwind, and code Playground
by MItul Patel
HTML
Content get from the "https://www.npmjs.com/package/fs-extra"
Fs-Extra.
fa-estra is extanded version on the fs in node js, By using FS-Extra we can manage the file and directory structure of the our system from the node js.
There are list of functions which provided into the fs-extra are as bellow.
copy & copySync
DESC
copy function is used for to copy file or dir from one place to another place it will create copy of file or dir
EXAPLE
fs.copy('/tmp/myfile', '/tmp/mynewfile', function (err) {
if (err) return console.error(err)
console.log("success!")
})
createOutputStream
This function is used for to create new file into the dir if the dir not exist then it will create dir automatically.
Ex.
var ws = fs.createOutputStream('/tmp/some/file.txt')
ws.write('hello\n')
this function will crate the file.txt and into the /tmp/some dir and write 'hello' in that file.
emptyDir emptyDirSync
This will check the dir if empty or not if the dir not exist then it will create the dir.
Ex.
fs.emptyDir('/tmp/some/dir', function (err) {
if (!err) console.log('success!')
})
ensureFile ensureFileSync
This fuction is used for to check the file exist or not if file is not exist then it will create the file and if the file exist then will do nothing no modification in existing file.
Ex.
var file = '/tmp/this/path/does/not/exist/file.txt'
fs.ensureFile(file, function (err) {
console.log(err) // => null
})
ensureDir ensureDirSync
This fuction is used for to check the dir exist or not if dir is not exist then it will create the dir and if the dir exist then will do nothing no modification in existing dir.
var dir = '/tmp/this/path/does/not/exist'
fs.ensureDir(dir, function (err) {
console.log(err) // => null
})
ensureLink ...