commonplace
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -156,8 +156,8 @@ var fs = require('fs'); | ||
function update_file(file) { | ||
fs.readFile(file, function(err, data) { | ||
fs.writeFile(file.replace(commonplace_src, local_src), data, function(err) { | ||
if (err) { | ||
console.error('Error updating ' + file, err); | ||
} | ||
}); | ||
var destination = file.replace(commonplace_src, local_src); | ||
utils.copyFile(file, destination, function(err) { | ||
if (err) { | ||
console.error('Error updating ' + destination) | ||
console.error(err); | ||
} | ||
}); | ||
@@ -164,0 +164,0 @@ } |
@@ -91,2 +91,29 @@ var fs = require('fs'); | ||
var createDir = module.exports.createDir = function(dir, callback) { | ||
var parent = path.dirname(dir); | ||
fs.exists(parent, function(exists) { | ||
function doMake() { | ||
if (fs.existsSync(dir)) { | ||
callback(); | ||
return; | ||
} | ||
fs.mkdir(dir, function(err) { | ||
callback(err); | ||
}); | ||
} | ||
if (exists) { | ||
doMake(); | ||
} else { | ||
createDir(parent, function(err) { | ||
if (err) { | ||
callback(err); | ||
return; | ||
} | ||
doMake(); | ||
}); | ||
} | ||
}); | ||
}; | ||
module.exports.copyFile = function(src, dest, callback) { | ||
@@ -98,9 +125,17 @@ fs.exists(src, function(exists) { | ||
} | ||
fs.readFile(src, function(err, data) { | ||
createDir(path.dirname(dest), function(err) { | ||
if (err) { | ||
if (callback) callback(err); | ||
console.error('Unable to create directory for ' + dest); | ||
console.error(err); | ||
return; | ||
} | ||
fs.writeFile(dest, data, function(err) { | ||
if (callback) callback(err); | ||
fs.readFile(src, function(err, data) { | ||
if (err) { | ||
if (callback) callback(err); | ||
return; | ||
} | ||
fs.writeFile(dest, data, function(err) { | ||
if (callback) callback(err); | ||
}); | ||
}); | ||
@@ -107,0 +142,0 @@ }); |
{ | ||
"name": "commonplace", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "url": "git://github.com/mozilla/commonplace.git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
854549
83
11348
12