Skip to content

Commit 799922e

Browse files
Formatting changes
1 parent 3f62dbb commit 799922e

File tree

4 files changed

+48
-48
lines changed

4 files changed

+48
-48
lines changed

bin/commands/runs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ module.exports = function run(args) {
5454
logger.warn(Constants.userMessages.NO_PARALLELS);
5555
}
5656

57-
if(!args.disableNpmWarning && bsConfig.run_settings.npm_dependencies && Object.keys(bsConfig.run_settings.npm_dependencies).length <= 0) logger.warn(Constants.userMessages.NO_NPM_DEPENDENCIES);
58-
57+
if (!args.disableNpmWarning && bsConfig.run_settings.npm_dependencies && Object.keys(bsConfig.run_settings.npm_dependencies).length <= 0) logger.warn(Constants.userMessages.NO_NPM_DEPENDENCIES);
58+
5959
logger.info(message);
6060
logger.info(dashboardLink);
6161
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null);

bin/helpers/utils.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ const os = require("os");
33
const path = require("path");
44
const fs = require("fs");
55

6-
const usageReporting = require('./usageReporting'),
6+
const usageReporting = require('./usageReporting'),
77
logger = require('./logger').winstonLogger,
88
Constants = require('./constants');
99

1010
exports.validateBstackJson = (bsConfigPath) => {
11-
return new Promise(function(resolve, reject){
11+
return new Promise(function (resolve, reject) {
1212
try {
1313
logger.info(`Reading config from ${bsConfigPath}`);
1414
let bsConfig = require(bsConfigPath);
1515
resolve(bsConfig);
1616
}
1717
catch (e) {
18-
reject("Couldn't find the browserstack.json file at \""+ bsConfigPath +"\". Please use --config-file <path to browserstack.json>.");
18+
reject("Couldn't find the browserstack.json file at \"" + bsConfigPath + "\". Please use --config-file <path to browserstack.json>.");
1919
}
2020
});
2121
}
@@ -51,7 +51,7 @@ exports.getErrorCodeFromMsg = (errMsg) => {
5151
errorCode = "invalid_directory_structure";
5252
break;
5353
}
54-
if(errMsg.includes("Please use --config-file <path to browserstack.json>.")){
54+
if (errMsg.includes("Please use --config-file <path to browserstack.json>.")) {
5555
errorCode = "bstack_json_path_invalid";
5656
}
5757
return errorCode;
@@ -96,7 +96,7 @@ exports.setParallels = (bsConfig, args) => {
9696
exports.setUsername = (bsConfig, args) => {
9797
if (!this.isUndefined(args.username)) {
9898
bsConfig['auth']['username'] = args.username;
99-
}else if(!this.isUndefined(process.env.BROWSERSTACK_USERNAME)){
99+
} else if (!this.isUndefined(process.env.BROWSERSTACK_USERNAME)) {
100100
bsConfig['auth']['username'] = process.env.BROWSERSTACK_USERNAME;
101101
logger.info("Reading username from the environment variable BROWSERSTACK_USERNAME");
102102
}
@@ -105,7 +105,7 @@ exports.setUsername = (bsConfig, args) => {
105105
exports.setAccessKey = (bsConfig, args) => {
106106
if (!this.isUndefined(args.key)) {
107107
bsConfig['auth']['access_key'] = args.key;
108-
}else if (!this.isUndefined(process.env.BROWSERSTACK_ACCESS_KEY)) {
108+
} else if (!this.isUndefined(process.env.BROWSERSTACK_ACCESS_KEY)) {
109109
bsConfig['auth']['access_key'] = process.env.BROWSERSTACK_ACCESS_KEY;
110110
logger.info("Reading access key from the environment variable BROWSERSTACK_ACCESS_KEY");
111111
}
@@ -122,14 +122,14 @@ exports.isUndefined = value => (value === undefined || value === null);
122122
exports.isFloat = value => (Number(value) && Number(value) % 1 !== 0);
123123

124124
exports.isParallelValid = (value) => {
125-
return this.isUndefined(value) || !(isNaN(value) || this.isFloat(value) || parseInt(value, 10) === 0 || parseInt(value, 10) < -1 ) || value === Constants.constants.DEFAULT_PARALLEL_MESSAGE;
125+
return this.isUndefined(value) || !(isNaN(value) || this.isFloat(value) || parseInt(value, 10) === 0 || parseInt(value, 10) < -1) || value === Constants.constants.DEFAULT_PARALLEL_MESSAGE;
126126
}
127127

128128
exports.getUserAgent = () => {
129129
return `BStack-Cypress-CLI/1.3.0 (${os.arch()}/${os.platform()}/${os.release()})`;
130130
}
131131

132-
exports.isAbsolute = (configPath) => {
132+
exports.isAbsolute = (configPath) => {
133133
return path.isAbsolute(configPath)
134134
}
135135

@@ -144,25 +144,25 @@ exports.configCreated = (args) => {
144144
}
145145

146146
exports.exportResults = (buildId, buildUrl) => {
147-
let data = "BUILD_ID=" + buildId + "\nBUILD_URL="+buildUrl;
148-
fs.writeFileSync("log/build_results.txt", data , function(err){
149-
if(err) {
147+
let data = "BUILD_ID=" + buildId + "\nBUILD_URL=" + buildUrl;
148+
fs.writeFileSync("log/build_results.txt", data, function (err) {
149+
if (err) {
150150
logger.warn(`Couldn't write BUILD_ID with value: ${buildId} to browserstack/build_results.txt`);
151151
logger.warn(`Couldn't write BUILD_URL with value: ${buildUrl} to browserstack/build_results.txt`);
152152
}
153153
});
154154
}
155155

156156
exports.deleteResults = () => {
157-
fs.unlink("log/build_results.txt", function (err){
157+
fs.unlink("log/build_results.txt", function (err) {
158158
});
159159
}
160160

161161
exports.isCypressProjDirValid = (cypressDir, cypressProjDir) => {
162162
// Getting absolute path
163163
cypressDir = path.resolve(cypressDir);
164164
cypressProjDir = path.resolve(cypressProjDir);
165-
if(cypressProjDir === cypressDir) return true;
165+
if (cypressProjDir === cypressDir) return true;
166166
let parentTokens = cypressDir.split('/').filter(i => i.length);
167167
let childTokens = cypressProjDir.split('/').filter(i => i.length);
168168
return parentTokens.every((t, i) => childTokens[i] === t);
@@ -173,16 +173,16 @@ exports.getLocalFlag = (connectionSettings) => {
173173
}
174174

175175
exports.setLocal = (bsConfig) => {
176-
if(!this.isUndefined(process.env.BROWSERSTACK_LOCAL)){
176+
if (!this.isUndefined(process.env.BROWSERSTACK_LOCAL)) {
177177
let local = false;
178-
if(String(process.env.BROWSERSTACK_LOCAL).toLowerCase() === "true") local = true;
178+
if (String(process.env.BROWSERSTACK_LOCAL).toLowerCase() === "true") local = true;
179179
bsConfig['connection_settings']['local'] = local;
180180
logger.info("Reading local setting from the environment variable BROWSERSTACK_LOCAL");
181181
}
182182
}
183183

184184
exports.setLocalIdentifier = (bsConfig) => {
185-
if (!this.isUndefined(process.env.BROWSERSTACK_LOCAL_IDENTIFIER)){
185+
if (!this.isUndefined(process.env.BROWSERSTACK_LOCAL_IDENTIFIER)) {
186186
bsConfig['connection_settings']['local_identifier'] = process.env.BROWSERSTACK_LOCAL_IDENTIFIER;
187187
logger.info("Reading local identifier from the environment variable BROWSERSTACK_LOCAL_IDENTIFIER");
188188
}

test/unit/bin/commands/runs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("runs", () => {
5151
},
5252
});
5353

54-
validateBstackJsonStub.returns(Promise.reject({message: "random-error"}));
54+
validateBstackJsonStub.returns(Promise.reject({ message: "random-error" }));
5555

5656
return runs(args)
5757
.then(function (_bsConfig) {

test/unit/bin/helpers/utils.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe("utils", () => {
105105
"parallels": 10,
106106
}
107107
};
108-
utils.setParallels(bsConfig, {parallels: 100});
108+
utils.setParallels(bsConfig, { parallels: 100 });
109109
expect(bsConfig['run_settings']['parallels']).to.be.eq(100);
110110
});
111111

@@ -115,7 +115,7 @@ describe("utils", () => {
115115
"parallels": 10,
116116
}
117117
};
118-
utils.setParallels(bsConfig, {parallels: undefined});
118+
utils.setParallels(bsConfig, { parallels: undefined });
119119
expect(bsConfig['run_settings']['parallels']).to.be.eq(10);
120120
});
121121
});
@@ -126,8 +126,8 @@ describe("utils", () => {
126126
});
127127

128128
it(`should return value depending on validation messages`, () => {
129-
expect(utils.getErrorCodeFromErr({"code": "SyntaxError"})).to.eq("bstack_json_parse_error");
130-
expect(utils.getErrorCodeFromErr({"code": "EACCES"})).to.eq("bstack_json_no_permission");
129+
expect(utils.getErrorCodeFromErr({ "code": "SyntaxError" })).to.eq("bstack_json_parse_error");
130+
expect(utils.getErrorCodeFromErr({ "code": "EACCES" })).to.eq("bstack_json_no_permission");
131131
});
132132
});
133133

@@ -139,15 +139,15 @@ describe("utils", () => {
139139

140140
describe("validateBstackJson", () => {
141141
it("should reject with SyntaxError for empty file", () => {
142-
let bsConfigPath = path.join(process.cwd(),'test', 'test_files', 'dummy_bstack.json');
142+
let bsConfigPath = path.join(process.cwd(), 'test', 'test_files', 'dummy_bstack.json');
143143
expect(utils.validateBstackJson(bsConfigPath)).to.be.rejectedWith(SyntaxError);
144144
});
145145
it("should resolve with data for valid json", () => {
146-
let bsConfigPath = path.join(process.cwd(),'test', 'test_files', 'dummy_bstack_2.json');
146+
let bsConfigPath = path.join(process.cwd(), 'test', 'test_files', 'dummy_bstack_2.json');
147147
expect(utils.validateBstackJson(bsConfigPath)).to.be.eventually.eql({});
148148
});
149149
it("should reject with SyntaxError for invalid json file", () => {
150-
let bsConfigPath = path.join(process.cwd(),'test', 'test_files', 'dummy_bstack_3.json');
150+
let bsConfigPath = path.join(process.cwd(), 'test', 'test_files', 'dummy_bstack_3.json');
151151
expect(utils.validateBstackJson(bsConfigPath)).to.be.rejectedWith(SyntaxError);
152152
});
153153
});
@@ -271,18 +271,18 @@ describe("utils", () => {
271271
fs.unlink.restore();
272272
});
273273
});
274-
274+
275275
describe("isCypressProjDirValid", () => {
276-
it("should return true when cypressDir and cypressProjDir is same", () =>{
277-
expect(utils.isCypressProjDirValid("/absolute/path","/absolute/path")).to.be.true;
276+
it("should return true when cypressDir and cypressProjDir is same", () => {
277+
expect(utils.isCypressProjDirValid("/absolute/path", "/absolute/path")).to.be.true;
278278
});
279279

280-
it("should return true when cypressProjDir is child directory of cypressDir", () =>{
281-
expect(utils.isCypressProjDirValid("/absolute/path","/absolute/path/childpath")).to.be.true;
280+
it("should return true when cypressProjDir is child directory of cypressDir", () => {
281+
expect(utils.isCypressProjDirValid("/absolute/path", "/absolute/path/childpath")).to.be.true;
282282
});
283283

284-
it("should return false when cypressProjDir is not child directory of cypressDir", () =>{
285-
expect(utils.isCypressProjDirValid("/absolute/path","/absolute")).to.be.false;
284+
it("should return false when cypressProjDir is not child directory of cypressDir", () => {
285+
expect(utils.isCypressProjDirValid("/absolute/path", "/absolute")).to.be.false;
286286
});
287287
});
288288

@@ -296,14 +296,14 @@ describe("utils", () => {
296296
});
297297

298298
it("should return false if connectionSettings.local is false", () => {
299-
expect(utils.getLocalFlag({"local": false})).to.be.false;
299+
expect(utils.getLocalFlag({ "local": false })).to.be.false;
300300
});
301301

302302
it("should return true if connectionSettings.local is true", () => {
303-
expect(utils.getLocalFlag({"local": true})).to.be.true;
303+
expect(utils.getLocalFlag({ "local": true })).to.be.true;
304304
});
305305
});
306-
306+
307307
describe("setLocal", () => {
308308
beforeEach(function () {
309309
delete process.env.BROWSERSTACK_LOCAL;
@@ -408,34 +408,34 @@ describe("utils", () => {
408408
delete process.env.BROWSERSTACK_USERNAME;
409409
});
410410

411-
it("should set username if args.username is present", () =>{
411+
it("should set username if args.username is present", () => {
412412
let bsConfig = {
413413
auth: {
414414
username: "test"
415415
}
416416
}
417-
utils.setUsername(bsConfig,{username: "username"});
417+
utils.setUsername(bsConfig, { username: "username" });
418418
expect(bsConfig.auth.username).to.be.eq("username");
419419
});
420420

421-
it("should set username if process.env.BROWSERSTACK_USERNAME is present and args.username is not present", () =>{
421+
it("should set username if process.env.BROWSERSTACK_USERNAME is present and args.username is not present", () => {
422422
let bsConfig = {
423423
auth: {
424424
username: "test"
425425
}
426426
}
427427
process.env.BROWSERSTACK_USERNAME = "username"
428-
utils.setUsername(bsConfig,{});
428+
utils.setUsername(bsConfig, {});
429429
expect(bsConfig.auth.username).to.be.eq("username");
430430
});
431431

432-
it("should set username to default if process.env.BROWSERSTACK_USERNAME and args.username is not present", () =>{
432+
it("should set username to default if process.env.BROWSERSTACK_USERNAME and args.username is not present", () => {
433433
let bsConfig = {
434434
auth: {
435435
username: "test"
436436
}
437437
}
438-
utils.setUsername(bsConfig,{});
438+
utils.setUsername(bsConfig, {});
439439
expect(bsConfig.auth.username).to.be.eq("test");
440440
});
441441

@@ -450,34 +450,34 @@ describe("utils", () => {
450450
delete process.env.BROWSERSTACK_ACCESS_KEY;
451451
});
452452

453-
it("should set access_key if args.key is present", () =>{
453+
it("should set access_key if args.key is present", () => {
454454
let bsConfig = {
455455
auth: {
456456
access_key: "test"
457457
}
458458
}
459-
utils.setAccessKey(bsConfig,{key: "access_key"});
459+
utils.setAccessKey(bsConfig, { key: "access_key" });
460460
expect(bsConfig.auth.access_key).to.be.eq("access_key");
461461
});
462462

463-
it("should set access_key if process.env.BROWSERSTACK_ACCESS_KEY is present and args.access_key is not present", () =>{
463+
it("should set access_key if process.env.BROWSERSTACK_ACCESS_KEY is present and args.access_key is not present", () => {
464464
let bsConfig = {
465465
auth: {
466466
access_key: "test"
467467
}
468468
}
469469
process.env.BROWSERSTACK_ACCESS_KEY = "access_key"
470-
utils.setAccessKey(bsConfig,{});
470+
utils.setAccessKey(bsConfig, {});
471471
expect(bsConfig.auth.access_key).to.be.eq("access_key");
472472
});
473473

474-
it("should set access_key to default if process.env.BROWSERSTACK_ACCESS_KEY and args.access_key is not present", () =>{
474+
it("should set access_key to default if process.env.BROWSERSTACK_ACCESS_KEY and args.access_key is not present", () => {
475475
let bsConfig = {
476476
auth: {
477477
access_key: "test"
478478
}
479479
}
480-
utils.setAccessKey(bsConfig,{});
480+
utils.setAccessKey(bsConfig, {});
481481
expect(bsConfig.auth.access_key).to.be.eq("test");
482482
});
483483

0 commit comments

Comments
 (0)