Skip to content

Commit 864c3e2

Browse files
committed
Util method to generate config path with the help of path
1 parent 3131e98 commit 864c3e2

File tree

6 files changed

+25
-15
lines changed

6 files changed

+25
-15
lines changed

bin/commands/info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const config = require("../helpers/config"),
77
utils = require("../helpers/utils");
88

99
module.exports = function info(args) {
10-
let bsConfigPath = process.cwd() + args.cf;
10+
let bsConfigPath = utils.getConfigPath(args.cf);
1111

1212
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
1313
// accept the username from command line if provided

bin/commands/runs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const archiver = require("../helpers/archiver"),
1010
fileHelpers = require("../helpers/fileHelpers");
1111

1212
module.exports = function run(args) {
13-
let bsConfigPath = process.cwd() + args.cf;
13+
let bsConfigPath = utils.getConfigPath(args.cf);
1414

1515
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
1616
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);

bin/commands/stop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const config = require("../helpers/config"),
77
utils = require("../helpers/utils");
88

99
module.exports = function stop(args) {
10-
let bsConfigPath = process.cwd() + args.cf;
10+
let bsConfigPath = utils.getConfigPath(args.cf);
1111

1212
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
1313
// accept the username from command line if provided

bin/helpers/utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const os = require("os");
3+
const path = require("path");
34

45
const usageReporting = require('./usageReporting'),
56
logger = require('./logger').winstonLogger,
@@ -105,3 +106,12 @@ exports.isParallelValid = (value) => {
105106
exports.getUserAgent = () => {
106107
return `BStack-Cypress-CLI/1.2.0 (${os.arch()}/${os.platform()}/${os.release()})`;
107108
}
109+
110+
exports.isAbsolute = (configPath) => {
111+
return path.isAbsolute(configPath)
112+
}
113+
114+
exports.getConfigPath = (configPath) => {
115+
console.log(configPath)
116+
return this.isAbsolute(configPath) ? configPath : path.join(process.cwd(), configPath);
117+
}

bin/runner.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var argv = yargs
5151
'cf': {
5252
alias: 'config-file',
5353
describe: Constants.cliMessages.BUILD.DESC,
54-
default: '/browserstack.json',
54+
default: 'browserstack.json',
5555
type: 'string',
5656
nargs: 1,
5757
demand: true,
@@ -91,7 +91,7 @@ var argv = yargs
9191
'cf': {
9292
alias: 'config-file',
9393
describe: Constants.cliMessages.BUILD.DESC,
94-
default: '/browserstack.json',
94+
default: 'browserstack.json',
9595
type: 'string',
9696
nargs: 1,
9797
demand: true,
@@ -130,7 +130,7 @@ var argv = yargs
130130
'cf': {
131131
alias: 'config-file',
132132
describe: Constants.cliMessages.RUN.DESC,
133-
default: '/browserstack.json',
133+
default: 'browserstack.json',
134134
type: 'string',
135135
nargs: 1,
136136
demand: true,

test/unit/support/fixtures/testObjects.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const initSampleArgs = {
1919

2020
const buildInfoSampleArgs = {
2121
_: ["build-info", "f3c94f7203792d03a75be3912d19354fe0961e53"],
22-
cf: "/browserstack.json",
23-
"config-file": "/browserstack.json",
24-
configFile: "/browserstack.json",
22+
cf: "browserstack.json",
23+
"config-file": "browserstack.json",
24+
configFile: "browserstack.json",
2525
"disable-usage-reporting": undefined,
2626
disableUsageReporting: undefined,
2727
$0: "browserstack-cypress",
@@ -81,9 +81,9 @@ const buildInfoSampleBody = {
8181

8282
const buildStopSampleArgs = {
8383
_: ["build-stop", "f3c94f7203792d03a75be3912d19354fe0961e53"],
84-
cf: "/browserstack.json",
85-
"config-file": "/browserstack.json",
86-
configFile: "/browserstack.json",
84+
cf: "browserstack.json",
85+
"config-file": "browserstack.json",
86+
configFile: "browserstack.json",
8787
"disable-usage-reporting": undefined,
8888
disableUsageReporting: undefined,
8989
$0: "browserstack-cypress",
@@ -100,9 +100,9 @@ const sampleCapsData = {
100100

101101
const runSampleArgs = {
102102
_: ["run"],
103-
cf: "/browserstack.json",
104-
"config-file": "/browserstack.json",
105-
configFile: "/browserstack.json",
103+
cf: "browserstack.json",
104+
"config-file": "browserstack.json",
105+
configFile: "browserstack.json",
106106
"disable-usage-reporting": undefined,
107107
p: undefined,
108108
"parallels": undefined,

0 commit comments

Comments
 (0)