receive both the "message" and the "curlCommand". Added a "tracer" logger which allows you to create log files that a executable scripts. Those scripts will write all of the log messages as script comments, and not comment out the curlCommands, so that they can trace their application and use the generated script to recreate the issue. Most changes are simply cased by adding the "unused" rule to jshint.
36 lines
878 B
JavaScript
36 lines
878 B
JavaScript
var fs = require('fs');
|
|
/**
|
|
* Stupid simple recursive file/directory clearing. Nothing serious.
|
|
*
|
|
* @param {String} path Location of the file/directory which should be wiped out
|
|
* @return {Boolean} frue on success
|
|
*/
|
|
module.exports = function (path) {
|
|
try {
|
|
var stats = fs.statSync(path);
|
|
if (stats && stats.isDirectory()) {
|
|
console.log('removing', path, 'directory recursively');
|
|
rmDirRecursive(path);
|
|
} else {
|
|
console.log('removing', path);
|
|
fs.unlinkSync(path);
|
|
}
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
|
|
function rmDirRecursive(path) {
|
|
fs.readdirSync(path).forEach(function (file) {
|
|
var curPath = path + '/' + file;
|
|
if (fs.statSync(curPath).isDirectory()) { // recurse
|
|
rmDirRecursive(curPath);
|
|
} else { // delete file
|
|
fs.unlinkSync(curPath);
|
|
}
|
|
});
|
|
fs.rmdirSync(path);
|
|
}
|