Node.js doesn’t have a filesystem method for cp, so here’s a tiny snippet of code for quick and dirty copying:
var fs = require("filesystem");
fs.cp = function(source, dest, callback){
var copy = require("child_process").spawn("cp", ["-r", source, dest]);
return copy.on("exit", callback);
};
fs.cp("file.txt", "file2.txt", function(err){
if(err) throw err;
console.log("copied file1.txt to file2.txt");
});