Skip to content

Commit ec1d8ca

Browse files
author
Rohan Jain
committed
Support for build and project name
1 parent 9b3483d commit ec1d8ca

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

bin/runner.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ function launchBrowser(browser) {
6666
url += '_worker_key=' + key + '&_browser_string=' + browserString;
6767
browser['url'] = url;
6868

69+
if (config.project) {
70+
browser.project = config.project;
71+
}
72+
if (config.build) {
73+
browser.build = config.build;
74+
}
75+
6976
client.createWorker(browser, function (err, worker) {
7077
var runningChecked = false;
7178

lib/config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ try {
1414
process.exit(1);
1515
}
1616

17+
try {
18+
var package_json = require(process.cwd() + '/package.json');
19+
} catch (e) {
20+
var package_json = {};
21+
}
22+
1723
if (process.env.BROWSERSTACK_KEY) {
1824
config.key = process.env.BROWSERSTACK_KEY;
1925
}
@@ -22,6 +28,18 @@ if (process.env.BROWSERSTACK_USERNAME) {
2228
config.username = process.env.BROWSERSTACK_USERNAME;
2329
}
2430

31+
if (!config.project) {
32+
var fallback_project;
33+
34+
if (config.username === 'OpensourceJSLib') {
35+
fallback_project = 'Anonymous OpenSource Project';
36+
}
37+
38+
config.project = process.env.TRAVIS_REPO_SLUG || package_json.name;
39+
}
40+
41+
config.build = process.env.TRAVIS_COMMIT;
42+
2543
['username', 'key', 'test_path', 'browsers'].forEach(function (param) {
2644
if (typeof config[param] === 'undefined') {
2745
console.error('Configuration parameter `%s` is required.', param);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "browserstack-runner",
33
"description": "A command line interface to run browser tests over BrowserStack",
4-
"version": "0.0.6",
4+
"version": "0.0.7",
55
"homepage": "https://github.com/browserstack/browserstack-runner",
66
"repository": {
77
"type": "git",

0 commit comments

Comments
 (0)