mili
Version:
vue + koa isomorphic boilerplate
22 lines (17 loc) • 380 B
JavaScript
const fs = require('fs')
module.exports = file => {
if (file.targetFile) return file
try {
fs.accessSync(file.targetPath, fs.constants.F_OK)
} catch(e) {
return { ...file, targetFile: { exist: false } }
}
const content = fs.readFileSync(file.targetPath, file.encoding)
return {
...file,
targetFile: {
exist: true,
content,
},
}
}