it is a npm package that provides fs function, with file existed check before file write.
$ npm install --save filehelper
- replace the old one, while the file is existed
- create new one, while the file is not existed
var filehelper = require("filehelper")
var str = ' I love Peter 3';
filehelper.write('./data.json', str)
.then( res=> {console.log('file is created');})
var filehelper = require("filehelper")
filehelper.read('./data.json')
.then( res=> {console.log(res)})
MIT © Waheng Chang