Skip to content

Commit 15bdc58

Browse files
committed
Cleanup code formatting and jshint errors
1 parent cb8ec37 commit 15bdc58

File tree

6 files changed

+183
-166
lines changed

6 files changed

+183
-166
lines changed

lib/_patch/mocha-plugin.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function(){
1+
(function() {
22
function stack(err) {
33
var str = err.stack || err.toString();
44

@@ -20,39 +20,39 @@
2020
return test.fullTitle().replace(/#/g, '');
2121
}
2222

23-
return Mocha.BrowserStack = function (runner, root) {
23+
return Mocha.BrowserStack = function(runner, root) {
2424
Mocha.reporters.HTML.call(this, runner, root);
2525

2626
var count = 1,
27-
that = this,
28-
failures = 0,
29-
passes = 0,
30-
start = 0,
31-
tracebacks = [];
27+
that = this,
28+
failures = 0,
29+
passes = 0,
30+
start = 0,
31+
tracebacks = [];
3232

33-
runner.on('start', function () {
33+
runner.on('start', function() {
3434
start = (new Date).getTime();
3535
});
36-
37-
runner.on('test end', function (test) {
36+
37+
runner.on('test end', function(test) {
3838
count += 1;
3939
});
40-
41-
runner.on('pass', function (test) {
40+
41+
runner.on('pass', function(test) {
4242
passes += 1;
4343
});
44-
45-
runner.on('fail', function (test, err) {
44+
45+
runner.on('fail', function(test, err) {
4646
failures += 1;
47-
47+
4848
if (err) {
49-
tracebacks.push(err);
49+
tracebacks.push(err);
5050
}
5151
});
52-
53-
runner.on('end', function () {
54-
results = {}
55-
results.runtime = ((new Date).getTime() - start);
52+
53+
runner.on('end', function() {
54+
results = {};
55+
results.runtime = Date.now() - start;
5656
results.total = passes + failures;
5757
results.passed = passes;
5858
results.failed = failures;

lib/_patch/qunit-plugin.js

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,58 @@
1-
// For logging assertions on the console, here's what grunt-contrib-qunit uses:
1+
// For logging assertions on the console, here's what grunt-contrib-qunit uses:
22
// https://github.com/gruntjs/grunt-contrib-qunit/blob/784597023e7235337ca9c0651aa45124a2d72341/tasks/qunit.js#L45
3-
(function(){
3+
(function() {
44

55
var failedAssertions = [];
6-
var options, currentModule, currentTest, setTimeoutVariable;
6+
var options,
7+
currentModule,
8+
currentTest,
9+
setTimeoutVariable;
710
var pendingTest = {};
811

912
var testTimeout = function() {
1013
var error = {
11-
testName: currentTest, message: "Stuck on this test for 60 sec."
12-
}
13-
14-
BrowserStack.post('/_progress', {tracebacks: [error]}, function(){});
15-
}
14+
testName: currentTest,
15+
message: "Stuck on this test for 60 sec."
16+
};
17+
18+
BrowserStack.post('/_progress', {
19+
tracebacks: [error]
20+
}, function(){});
21+
};
1622

17-
QUnit.testDone(function( details ) {
23+
QUnit.testDone(function(details) {
1824
var ct = details.module + " - " + details.name;
1925
clearTimeout(pendingTest[ct]);
2026
});
2127

22-
QUnit.testStart(function( details ) {
28+
QUnit.testStart(function(details) {
2329
currentTest = details.module + " - " + details.name;
24-
pendingTest[currentTest] = setTimeout(function(){
30+
pendingTest[currentTest] = setTimeout(function() {
2531
testTimeout(currentTest);
2632
}, 60000);
2733
});
28-
29-
QUnit.log(function( details ) {
30-
if ( details.result ) {
34+
35+
QUnit.log(function(details) {
36+
if (details.result) {
3137
return;
3238
}
33-
39+
3440
var error = {
35-
actual: details.actual, expected: encodeURIComponent(details.expected), message: encodeURIComponent(details.message), source: encodeURIComponent(details.source),
36-
testName: (details.module + ": " + details.name)
37-
}
38-
39-
BrowserStack.post('/_progress', {tracebacks: [error]}, function(){});
41+
actual: details.actual,
42+
expected: encodeURIComponent(details.expected),
43+
message: encodeURIComponent(details.message),
44+
source: encodeURIComponent(details.source),
45+
testName:( details.module + ": " + details.name)
46+
};
47+
48+
BrowserStack.post('/_progress', {
49+
tracebacks: [error]
50+
}, function(){});
4051
});
41-
42-
QUnit.done(function( results ) {
52+
53+
QUnit.done(function(results) {
4354
results.url = window.location.pathname;
4455
BrowserStack.post("/_report", results, function(){});
4556
});
46-
57+
4758
})();

lib/config.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var path = require('path'),
2-
fs = require('fs');
2+
fs = require('fs');
33
var pwd = process.cwd();
44

55
config_path = process.env.BROWSERSTACK_JSON || 'browserstack.json';
@@ -46,10 +46,10 @@ if (!config.project) {
4646
var commit_id = process.env.TRAVIS_COMMIT;
4747

4848
if (commit_id) {
49-
config.build = "Commit-" + commit_id.slice(0, commit_id.length/2);
49+
config.build = "Commit-" + commit_id.slice(0, commit_id.length / 2);
5050
}
5151

52-
['username', 'key', 'test_path', 'browsers'].forEach(function (param) {
52+
['username', 'key', 'test_path', 'browsers'].forEach(function(param) {
5353
if (typeof config[param] === 'undefined') {
5454
console.error('Configuration parameter `%s` is required.', param);
5555
process.exit(1);
@@ -58,27 +58,27 @@ if (commit_id) {
5858

5959
var formatPath = function(path) {
6060
if (path.indexOf(pwd) === 0) {
61-
path= path.slice(pwd.length + 1);
61+
path = path.slice(pwd.length + 1);
6262
}
63-
if (!fs.existsSync(path)){
64-
console.error('Test path: '+ path + ' is invalid.');
63+
if (!fs.existsSync(path)) {
64+
console.error('Test path: ' + path + ' is invalid.');
6565
process.exit(1);
6666
}
6767
return path;
68-
}
68+
};
6969

7070
config.tunnelIdentifier = process.env.TUNNEL_ID || process.env.TRAVIS_JOB_ID || process.env.TRAVIS_BUILD_ID;
7171

72-
if(Object.prototype.toString.call(config.test_path) === '[object Array]') {
73-
config.test_path.forEach(function(path){
72+
if (Object.prototype.toString.call(config.test_path) === '[object Array]') {
73+
config.test_path.forEach(function(path) {
7474
path = formatPath(path);
7575
});
7676
} else {
7777
//Backward Compatibility, if test_path is not array of path
7878
config.test_path = formatPath(config.test_path);
7979
}
8080

81-
for (key in config) {
81+
for (var key in config) {
8282
if (config.hasOwnProperty(key)) {
8383
exports[key] = config[key];
8484
}

lib/local.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
var exec = require('child_process').exec,
2-
fs = require('fs'),
3-
http = require('http'),
4-
windows = ((process.platform.match(/win32/) || process.platform.match(/win64/)) != null),
5-
localBinary = __dirname + (windows ? '/BrowserStackTunnel.jar' : '/BrowserStackLocal'),
6-
utils = require('./utils'),
7-
config = require('./config');
2+
fs = require('fs'),
3+
http = require('http'),
4+
windows = ((process.platform.match(/win32/) || process.platform.match(/win64/)) !== null),
5+
localBinary = __dirname + (windows ? '/BrowserStackTunnel.jar' : '/BrowserStackLocal'),
6+
utils = require('./utils'),
7+
config = require('./config');
88

9-
var Tunnel = function Tunnel (key, port, uniqueIdentifier, callback, err) {
9+
var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) {
1010
var that = {};
1111

12-
function tunnelLauncher () {
12+
function tunnelLauncher() {
1313
var tunnelCommand = (windows ? 'java -jar ' : '') + localBinary + ' ';
14-
if (config.debug)
15-
tunnelCommand += ' -v ';
14+
if (config.debug) tunnelCommand += ' -v ';
1615
tunnelCommand += key + ' ';
1716
tunnelCommand += 'localhost' + ',';
1817
tunnelCommand += port.toString() + ',';
1918
tunnelCommand += '0';
20-
tunnelCommand += (typeof uniqueIdentifier === 'undefined')? ' -force -onlyAutomate' : ' -tunnelIdentifier ' + uniqueIdentifier;
19+
tunnelCommand += (typeof uniqueIdentifier === 'undefined') ? ' -force -onlyAutomate' : ' -tunnelIdentifier ' + uniqueIdentifier;
2120

2221
if (typeof callback !== 'function') {
23-
callback = function () {};
22+
callback = function(){};
2423
}
2524

2625
console.log("[%s] Launching tunnel", new Date());
27-
var subProcess = exec(tunnelCommand, function (error, stdout, stderr) {
26+
var subProcess = exec(tunnelCommand, function(error, stdout, stderr) {
2827
console.log(stderr);
2928
console.log(error);
3029
if (stdout.indexOf('Error') >= 0) {
@@ -38,13 +37,13 @@ var Tunnel = function Tunnel (key, port, uniqueIdentifier, callback, err) {
3837
var running = false;
3938
var runMatcher = "You can now access your local server(s)";
4039

41-
setTimeout(function () {
40+
setTimeout(function() {
4241
if (!running) {
4342
utils.alertBrowserStack("Tunnel launch timeout", 'Stdout:\n' + data);
4443
}
4544
}, 30 * 1000);
4645

47-
subProcess.stdout.on('data', function (_data) {
46+
subProcess.stdout.on('data', function(_data) {
4847
if (running) {
4948
return;
5049
}
@@ -61,7 +60,7 @@ var Tunnel = function Tunnel (key, port, uniqueIdentifier, callback, err) {
6160
that.process = subProcess;
6261
}
6362

64-
fs.exists(localBinary, function (exists) {
63+
fs.exists(localBinary, function(exists) {
6564
if (exists) {
6665
fs.unlinkSync(localBinary);
6766
// tunnelLauncher();
@@ -71,19 +70,20 @@ var Tunnel = function Tunnel (key, port, uniqueIdentifier, callback, err) {
7170

7271
var file = fs.createWriteStream(localBinary);
7372
var request = http.get(
74-
(windows ? "http://www.browserstack.com/BrowserStackTunnel.jar" : ("http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-" + process.platform + "-" + process.arch)),
75-
function(response) {
76-
response.pipe(file);
73+
(windows ? "http://www.browserstack.com/BrowserStackTunnel.jar" : ("http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-" + process.platform + "-" + process.arch)),
74+
function(response) {
75+
response.pipe(file);
7776

78-
response.on('end', function () {
79-
fs.chmodSync(localBinary, 0700);
80-
setTimeout(function() {tunnelLauncher();}, 100);
81-
});
82-
}
83-
);
77+
response.on('end', function() {
78+
fs.chmodSync(localBinary, 0700);
79+
setTimeout(function() {
80+
tunnelLauncher();
81+
}, 100);
82+
});
83+
});
8484
});
8585

8686
return that;
87-
}
87+
};
8888

8989
exports.Tunnel = Tunnel;

0 commit comments

Comments
 (0)