I'm trying to overwrite an existing file.
I'm first checking if the file exists using:
fs.existsSync(path)
If file does not exit I'm creating and writing using:
fs.writeFileSync(path,string)
The problem is when the file already exists and I want to over write all its contents.
Is there a single line solution, so far I searched and found solutions that use
fs.truncate & fs.write, but is there a one hit solution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…