nodejs拷贝文件
nodejs拷贝文件,跟python一样方便
const fs = require('fs-extra');
const ps = require('path');
(async () => {
let arrName = [
'xx.proto',
]
for (let i = 0; i < arrName.length; i++) {
const fname = arrName[i];
const orgnurl = ps.join(__dirname, '..', '..', 'Proto', fname);
const oururl = ps.join(__dirname, '..', '..', 'Proto', 'protobuf', fname);
var originalData = await fs.readFile(orgnurl, 'utf-8');
originalData = originalData.replace(`option go_package = "../protocol";`, `package Pb;`)
await fs.writeFile(
oururl,
originalData
);
}
})();
然后执行node ./copyPb.js
,拷贝成功~!