文件类的读写封装


const fs = window.require('fs').promises // const path = window.require('path')   const fileHelper = {     readFile:(path) => {         return fs.readFile(path,{encoding:'utf8'})     },     writeFile:(path,content) => {         return fs.writeFile(path,content,{encoding:'utf8'})     },     renameFile:(path,newPath) => {         return fs.rename(path,newPath)     },     deleteFile:(path) => {         return fs.unlink(path)     } }
export default fileHelper
// const testPath = path.join(__dirname,'helper.js') // fileHelper.readFile(testPath).then((data)=>{ //     console.log(data); // })
  //const testWrotePath = path.join(__dirname,'hello.md') // fileHelper.writeFile(testWrotePath,'## hello worl2222d').then(() => { //     console.log('写入成功'); // })
//   const renamePath = path.join(__dirname,'rename.md')
// fileHelper.renameFile(testWrotePath,renamePath).then(()=>{ //     console.log('重命名成功'); // })
// fileHelper.deleteFile(renamePath).then(()=>{ //     console.log( `${renamePath}  删除成功` ); // })