1.0.6 • Published 7 years ago
copy-document v1.0.6
Use: Copy a document to other document; Createing by Winux-R ; Email: 464940202@qq.com;
Useing-nodeJS-to-creating-a-cope-function
##Install with npm npm install copy-document
function copy(src, target, flag){
fs.readFile(src, "utf8", function (err, data) {
if (err) {
console.log(err);
} else if (data) {
if(flag === "w"){
fs.writeFile(target, data, {flag: flag}, function(err){
console.log(err);
})
} else if (flag === "a") {
fs.writeFile(target, data, {flag: flag}, function(err){
console.log(err);
})
} else {
console.log("flag is not right");
}
}
});
}