making it possible to have relative/abs result dir, thanks @allocbool #449
This commit is contained in:
parent
8c21d672de
commit
a03e1fff95
17
lib/conf.js
17
lib/conf.js
|
|
@ -87,8 +87,11 @@ config = require("nomnom").options({
|
|||
default: 'sitespeed-result',
|
||||
help: 'The result base directory',
|
||||
callback: function(file) {
|
||||
if (!fs.existsSync(file))
|
||||
return "Couldn't find the basedir:" + file;
|
||||
if (!fs.existsSync(file)) {
|
||||
fs.mkdirs(file, function(err){
|
||||
if (err) return console.error("Couldn't create the result base dir:" + err);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
userAgent: {
|
||||
|
|
@ -285,15 +288,19 @@ config.run = {};
|
|||
config.run.date = new Date();
|
||||
|
||||
// Setup the absolute result dir
|
||||
|
||||
var startPath = (config.resultBaseDir.charAt(0) === path.sep) ? config.resultBaseDir : path.join(__dirname, '../',
|
||||
config.resultBaseDir);
|
||||
|
||||
if (config.url) {
|
||||
config.urlObject = urlParser.parse(config.url);
|
||||
config.run.absResultDir = path.join(__dirname, '../',config.resultBaseDir, config.urlObject.hostname, dateFormat(config.run.date, "yyyy-mm-dd-HH-MM-ss") );
|
||||
config.run.absResultDir = path.join(startPath, config.urlObject.hostname, dateFormat(config.run.date, "yyyy-mm-dd-HH-MM-ss") );
|
||||
} else if (config.file) {
|
||||
// TODO handle the file name in a good way if it contains chars that will not fit in a dir
|
||||
config.run.absResultDir = path.join(__dirname, '../',config.resultBaseDir, config.file, dateFormat(config.run.date, "yyyy-mm-dd-HH-MM-ss") );
|
||||
config.run.absResultDir = path.join(startPath, config.file, dateFormat(config.run.date, "yyyy-mm-dd-HH-MM-ss") );
|
||||
} else if (config.sites) {
|
||||
// The log file will end up here
|
||||
config.run.absResultDir = path.join(__dirname, '../',config.resultBaseDir, 'sites', dateFormat(config.run.date, "yyyy-mm-dd-HH-MM-ss"));
|
||||
config.run.absResultDir = path.join(startPath, 'sites', dateFormat(config.run.date, "yyyy-mm-dd-HH-MM-ss"));
|
||||
}
|
||||
|
||||
// Parse the proxy info as a real URL
|
||||
|
|
|
|||
|
|
@ -101,7 +101,11 @@ Runner.prototype._setupConfigurationForSite = function(args, cb) {
|
|||
var url = args.url;
|
||||
config.url = url;
|
||||
config.urlObject = urlParser.parse(config.url);
|
||||
config.run.absResultDir = path.join(__dirname, '../', config.resultBaseDir, 'sites', dateFormat(config.run.date,
|
||||
|
||||
var startPath = (config.resultBaseDir.charAt(0) === path.sep) ? config.resultBaseDir : path.join(__dirname, '../',
|
||||
config.resultBaseDir);
|
||||
|
||||
config.run.absResultDir = path.join(startPath, 'sites', dateFormat(config.run.date,
|
||||
"yyyy-mm-dd-HH-MM-ss"), config.urlObject.hostname);
|
||||
// setup the directories needed
|
||||
var dataDir = path.join(config.run.absResultDir, config.dataDir);
|
||||
|
|
|
|||
Loading…
Reference in New Issue