Last active
September 8, 2022 09:06
-
-
Save sabesansathananthan/aa2ba85035b33757f43896da1bbe2faf to your computer and use it in GitHub Desktop.
How to copy files and folders in Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs.readFile('./data.txt', { encoding: 'utf8' }, (err, data) => { | |
if (err) { | |
console.error(err); | |
return; | |
} | |
data = data.replace(/hi/gi, 'world'); | |
fs.writeFile('./info.txt', data, (err) => { | |
if (err) { | |
console.error(err); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment