Skip to content

Commit

Permalink
Merge pull request #169 from hassy/log-to-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
hassy authored Sep 13, 2016
2 parents e8393f9 + 5affa4b commit c4f1d51
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,26 @@ module.exports = run;
function run(scriptPath, options) {

let logfile;

let isDir = false;
if (options.output && options.output !== defaultOptions.output) {
logfile = options.output;
if (!logfile.match(/\.json$/)) {
logfile += '.json';
try {
isDir = fs.statSync(options.output).isDirectory();
} catch (err) {
// ENOENT, don't need to do anything
}
}

if (!isDir) {
logfile = options.output;
} else {
let filename = '';
if (defaultOptions.output) {
logfile = moment().format(defaultOptions.output);
filename = moment().format(defaultOptions.output);
} else {
logfile = moment().format('[artillery_report_]YMMDD_HHmmSS[.json]');
filename = moment().format('[artillery_report_]YMMDD_HHmmSS[.json]');
}
logfile = path.join(options.output, filename);
}

function log() {
Expand Down

0 comments on commit c4f1d51

Please sign in to comment.