Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
Adding overwriteExistingFiles argument, would overwrite files from "f1" with those from "f2"
  • Loading branch information
wvbe committed Mar 25, 2015
1 parent edcde25 commit 46302a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
var fs = require("node-fs");

module.exports = function mergeDirs(f1, f2) {
module.exports = function mergeDirs(f1, f2, overwriteExistingFiles) {
var file, files, stats, _i, _len, _results;
files = fs.readdirSync(f1);
_results = [];
Expand All @@ -23,7 +23,7 @@ module.exports = function mergeDirs(f1, f2) {
if (stats.isDirectory()) {
mergeDirs("" + f1 + "/" + file, "" + f2 + "/" + file)
} else {
if (!fs.existsSync("" + f2 + "/" + file)) {
if (!fs.existsSync("" + f2 + "/" + file) || overwriteExistingFiles) {
fs.mkdirSync(("" + f2 + "/" + file).split("/").slice(0, -1).join("/"), 0x1ed, true);
fs.writeFileSync("" + f2 + "/" + file, fs.readFileSync("" + f1 + "/" + file));
}
Expand Down

0 comments on commit 46302a0

Please sign in to comment.