To -> 中文
Node.js -> fs: Simple use tool
npm i rxfile-write --save-dev- Determine whether the
file/directoryexists Readeverything in thefileErasewrite content to file,oraddcontent to a fileDeletefile/directory
// node / cjsconstRxfileWrite=require('rxfile-write')// orimportRxfileWritefrom'rxfile-write'constpath=require('path')functionps(p){returnpath.resolve(__dirname,'..',p)}// - - RxfileWrite.read - -RxfileWrite.read(ps('LICENSE')).then(data=>{console.log('data\n\n',data)}).catch(err=>{console.log('read error=',err)})// - - RxfileWrite.exists - -RxfileWrite.exists(ps('LICENSE')).then(()=>{console.log('exists is ok')}).catch(err=>{console.log('exists error=',err)})// - - RxfileWrite.write - -RxfileWrite.write(ps('ttt.txt'),'hello world!').then(()=>{console.log('write succ')setTimeout(()=>{// - - RxfileWrite.remove - -RxfileWrite.remove(ps('ttt.txt')).then(()=>{console.log('remove succ')}).catch(err=>{console.log('remove error=',err)})},5000);}).catch(err=>{console.log('write error=',err)})- exists
- read
- cp
- cpSync
- write
- writeSync
- writeAppend
- writeAppendSync
- writeTo
- remove