Skip to content

Commit b70b681

Browse files
authored
Merge pull request #236 from LambdaTest/dev
3.0.12
2 parents d0d8aba + 33d1935 commit b70b681

File tree

8 files changed

+36
-23
lines changed

8 files changed

+36
-23
lines changed

commands/init.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ const { config } = require('yargs');
55
const constants = require('./utils/constants.js')
66

77
function create_file(file_path, content) {
8-
fs.writeFile(file_path, content, function (err) {
8+
fs.writeFileSync(file_path, content, function (err) {
99
if (err) throw err;
1010
console.log('Saved at ',file_path);
1111
});
12-
}
12+
};
1313

1414
function create_ltconfig_file(args) {
1515
let cv=9.6
@@ -47,14 +47,6 @@ function create_ltconfig_file(args) {
4747
}
4848
};
4949

50-
function create_base_reporter_config_file(args) {
51-
let config = require('./utils/default_reporter_config.js')
52-
let content = JSON.stringify(config, null, 3);
53-
if (args._.length == 1) {
54-
create_file(constants.LT_BASE_REPORTER_CONFIG_FILE_NAME, content)
55-
}
56-
};
57-
5850
function create_custom_support_file(args){
5951
const pathToFile = path.join(__dirname, "default_custom_support_file.js");
6052
const pathToNewDestination = constants.LT_BASE_CUSTOM_SUPPORT_FILE_NAME;
@@ -68,7 +60,16 @@ function create_custom_support_file(args){
6860
});
6961
}
7062

71-
module.exports = function (args) {
63+
function create_base_reporter_config_file(args) {
64+
let config = require('./utils/default_reporter_config.js')
65+
let content = JSON.stringify(config, null, 3);
66+
67+
if (args._.length == 1) {
68+
create_file(constants.LT_BASE_REPORTER_CONFIG_FILE_NAME, content)
69+
}
70+
};
71+
72+
function init_implementation(args){
7273
create_ltconfig_file(args);
7374
create_base_reporter_config_file(args);
7475
if ("cv" in args){
@@ -77,3 +78,7 @@ module.exports = function (args) {
7778
}
7879
}
7980
};
81+
module.exports = {
82+
create_base_reporter_config_file:create_base_reporter_config_file,
83+
init_implementation:init_implementation,
84+
};

commands/utils/batch/batcher.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ function get_spec_files(files, exclude_files) {
5252
remaining_files.push(matched_files[i]);
5353
}
5454
if (!fs.existsSync(matched_files[i])) {
55-
reject("Spec files are not present");
55+
reject("Error! Spec files are not present");
5656
}
5757
}
5858
if (remaining_files.length == 0) {
59-
reject("Spec files are not present");
59+
reject("Error! Spec files are not present");
6060
}
6161
resolve(remaining_files);
6262
});

commands/utils/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = {
3737
REPORT_URL:
3838
"https://api-envi-dev.lambdatestinternal.com/automation/api/v1/cypress/artefacts/test/",
3939
},
40+
4041
stage: {
4142
INTEGRATION_BASE_URL: "https://stage-api.lambdatestinternal.com/liis",
4243
BUILD_BASE_URL:

commands/utils/default_reporter_config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ module.exports = {
55
"overwrite": true,
66
"html": true,
77
"json": true
8-
}
9-
};
8+
}
9+
}

commands/utils/set_args.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const constants = require("./constants.js");
2+
var init_commands = require("./../init.js");
3+
24
const fs = require("fs");
35
const path = require("path");
46
const process = require("process");
@@ -237,6 +239,13 @@ function sync_args_from_cmd(args) {
237239
console.log(
238240
"Warning !! Value of reporter_config_file parameter missing. Proceeding with default reporter config"
239241
);
242+
// make sure that the default file exists on user system. If not, place it. There is a possibility that
243+
// user may have deleted it from her system/or not ran init command.
244+
if (!fs.existsSync(lt_config["run_settings"]["reporter_config_file"])) {
245+
console.log("!! Warning, Creating the default reporter config file");
246+
init_commands.create_base_reporter_config_file(args);
247+
248+
}
240249
lt_config["run_settings"]["reporter_config_file"] =
241250
constants.LT_BASE_REPORTER_CONFIG_FILE_NAME;
242251
}

commands/utils/validate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const semverCompare = require("semver/functions/compare");
44

55
const constants = require("./constants.js");
66
module.exports = validate_config = function (lt_config, validation_configs) {
7-
console.log("validating config");
7+
console.log("Validating lambdatest config");
88
return new Promise(function (resolve, reject) {
99
//validate auth keys are present
1010
if (
@@ -251,9 +251,9 @@ module.exports = validate_config = function (lt_config, validation_configs) {
251251
);
252252
}
253253
}
254-
} catch {
254+
} catch(e) {
255255
console.log(
256-
"reporter_config_file could not be parsed, please provide a valid json in Reporter Config"
256+
"reporter_config_file could not be parsed, please provide a valid json in Reporter Config - ", e
257257
);
258258
reject("Error!! Reporter JSON File does not have correct json");
259259
}

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#!/usr/bin/env node
22

3-
const { init } = require("./commands/init");
4-
53
const argv = require("yargs")
64
.usage("Usage: $0 <command> [options]")
75
.command(
86
"init",
9-
"create an intial config file",
7+
"create an initial config file",
108
function (yargs) {
119
return yargs
1210
.option("cv", {
@@ -21,7 +19,7 @@ const argv = require("yargs")
2119
});
2220
},
2321
function (argv) {
24-
require("./commands/init")(argv);
22+
require("./commands/init").init_implementation(argv);
2523
}
2624
)
2725
.command(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lambdatest-cypress-cli",
3-
"version": "3.0.11",
3+
"version": "3.0.12",
44
"description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.",
55
"homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli",
66
"author": "LambdaTest <keys@lambdatest.com>",

0 commit comments

Comments
 (0)