Merge branch 'tufandevrim-master'

This commit is contained in:
soulgalore 2015-08-10 11:01:45 +02:00
commit fa40fc2741
1 changed files with 20 additions and 4 deletions

View File

@ -26,6 +26,15 @@ var validatePathOption = function(optionName, path) {
}
};
var isJsonString = function(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
};
var cli = nomnom.help(
'sitespeed.io is a tool that helps you analyze your website performance and show you what you should optimize, more info at http://www.sitespeed.io.' +
EOL +
@ -404,13 +413,20 @@ var cli = nomnom.help(
help: 'The API key if running on webpagetest on the public instances.'
},
requestHeaders: {
metavar: '<FILE>',
help: 'Any request headers to use, a file with JSON form of {\"name\":\"value\",\"name2\":\"value\"}. Not supported for WPT & GPSI.',
metavar: '<FILE>|<HEADER>',
type: 'string',
help: 'Any request headers to use, a file or a header string with JSON form of {\"name\":\"value\",\"name2\":\"value\"}. Not supported for WPT & GPSI.',
callback: function(path) {
return validatePathOption('requestHeaders', path);
if (!fs.existsSync(path) && !isJsonString(path)) {
return '--requestHeaders: \'' + path + '\' is not a file or not a valid JSON header string!';
}
},
transform: function(path) {
return fileHelper.getFileAsJSON(path);
if (fs.existsSync(path)) {
return fileHelper.getFileAsJSON(path);
} else {
return JSON.parse(path);
}
}
},
postURL: {