Skip to content

Commit 8c0e208

Browse files
if no testingbot_key environment of key passed, try to check the ~/.testingbot file
1 parent 5754653 commit 8c0e208

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/api.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ function TestingBot(options) {
88
this.options = options || {};
99
this.options.api_key = process.env.TESTINGBOT_KEY || this.options.api_key || null;
1010
this.options.api_secret = process.env.TESTINGBOT_SECRET || this.options.api_secret || null;
11+
12+
if (!this.options.api_key || !this.options.api_secret) {
13+
var fs = require('fs');
14+
var path = require('path');
15+
16+
try {
17+
var tbFile = path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], '.testingbot');
18+
if (fs.statSync(tbFile).isFile() === true) {
19+
var data = fs.readFileSync(tbFile);
20+
if (data !== null) {
21+
var arr = data.toString().replace('\n', '').split(':');
22+
this.options.api_key = arr[0];
23+
this.options.api_secret = arr[1];
24+
}
25+
}
26+
} catch (e) {
27+
28+
}
29+
}
1130
}
1231

1332
TestingBot.prototype.getTestDetails = function(testID, callback) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "TestingBot <[email protected]> (testingbot.com)",
33
"name": "testingbot-api",
44
"description": "A wrapper around TestingBot's REST API",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"homepage": "https://github.com/testingbot/testingbot-api",
77
"repository": {
88
"type": "git",

0 commit comments

Comments
 (0)