Created
September 13, 2021 19:40
-
-
Save Victor-Villacis/1083ec4a4804c41e3db78c1754a6d276 to your computer and use it in GitHub Desktop.
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
'use strict' | |
//read, write and delete file using sync methodss. | |
const fs = require('fs'); | |
const data = fs.readFileSync('target.txt'); | |
fs.writeFileSync("turbo.txt", `I am from target.txt: ${data} this is take 2`); | |
process.stdout.write("\nFrom process stdout: " + data.toString()); | |
console.log("\nFrom console log: " + data.toString()) | |
const targetTxt = fs.readFileSync('turbo.txt'); | |
process.stdout.write("\nFrom process stdout2: " + targetTxt.toString()); | |
console.log("\nFrom console log2: " + targetTxt.toString()) | |
fs.copyFileSync("./turbo.txt", "./turbo2.txt") | |
setTimeout(() => { | |
fs.unlinkSync("./turbo2.txt") | |
}, 3000) | |
const targetTxt2 = fs.readFileSync('./turbo2.txt') | |
process.stdout.write(`\n${targetTxt2}: This file will be deleted`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment