Skip to content

Commit

Permalink
refactored run.js to use mkpath module instead of ensureDir which was…
Browse files Browse the repository at this point in the history
… not working on windows for saving reports
  • Loading branch information
beatfactor committed Feb 24, 2014
2 parents 4332aa3 + 6348c4b commit 51386c2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
8 changes: 4 additions & 4 deletions bin/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444
"port" : 4444
},

"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
Expand All @@ -32,7 +32,7 @@
"acceptSslCerts" : true
}
},

"saucelabs" : {
"selenium_host" : "ondemand.saucelabs.com",
"selenium_port" : 80,
Expand All @@ -50,7 +50,7 @@
"browserName": "firefox"
}
},

"browserstack" : {
"selenium_host" : "hub.browserstack.com",
"selenium_port" : 80,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"dependencies": {
"ejs": ">=0.8.3",
"optimist": ">=0.3.5",
"minimatch": "~0.2.14"
"minimatch": "~0.2.14",
"mkpath": ">=0.1.0"
},
"devDependencies": {
"nodeunit": "latest"
Expand Down
34 changes: 16 additions & 18 deletions runner/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var path = require('path');
var fs = require('fs');
var util = require('util');
var child_process = require('child_process');
var mkpath = require('mkpath');
var minimatch = require('minimatch');
var Nightwatch = require('../index.js');
var Logger = require('../lib/logger.js');
Expand Down Expand Up @@ -152,21 +153,6 @@ module.exports = new (function() {
};
}

function ensureDir(path, callback) {
var mkdir = child_process.spawn('mkdir', ['-p', path]);
mkdir.on('error', function (err) {
callback(err);
callback = function() {};
});
mkdir.on('exit', function (code) {
if (code === 0) {
callback();
} else {
callback(new Error('Error saving tests output. mkdir exited with code: ' + code));
}
});
}

function runFiles(paths, cb, opts) {
var extensionPattern = /\.js$/;
if (paths.length == 1 && extensionPattern.test(paths[0])) {
Expand Down Expand Up @@ -297,9 +283,21 @@ module.exports = new (function() {
if (output === false) {
finishCallback(null);
} else {
ensureDir(output, function() {
Reporter.save(globalresults, output);
finishCallback(null);
mkpath(output, function(err) {
if (err) {
console.log(Logger.colors.yellow('Output folder doesn\'t exist and cannot be created.'));
console.log(err.stack);
finishCallback(null);
return;
}

Reporter.save(globalresults, output, function(err) {
if (err) {
console.log(Logger.colors.yellow('Warning: Failed to save report file to folder: ' + output));
console.log(err.stack);
}
finishCallback(null);
});
});
}
}
Expand Down

0 comments on commit 51386c2

Please sign in to comment.