Skip to content

Commit 30f71f4

Browse files
Merge pull request #69 from LambdaTest/dev
Dev
2 parents f8d17bc + a8f9619 commit 30f71f4

File tree

6 files changed

+42
-8
lines changed

6 files changed

+42
-8
lines changed

commands/run.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@ module.exports = function (args) {
7373
.then((status) => {
7474
batch_runner
7575
.run_batches(lt_config, batches, env)
76-
.then(function () {
76+
.then(function (exit_code) {
7777
console.log("stopping tunnel");
7878
tunnelInstance.stop();
79+
if (
80+
lt_config["run_settings"]["exit-on-failure"]
81+
) {
82+
process.exit(exit_code);
83+
}
7984
})
8085
.catch(function (error) {
8186
console.log("stopping tunnel failed");
@@ -89,7 +94,18 @@ module.exports = function (args) {
8994
);
9095
});
9196
} else {
92-
batch_runner.run_batches(lt_config, batches, env);
97+
batch_runner
98+
.run_batches(lt_config, batches, env)
99+
.then(function (exit_code) {
100+
if (lt_config["run_settings"]["exit-on-failure"]) {
101+
process.exit(exit_code);
102+
}
103+
})
104+
.catch(function (error) {
105+
if (lt_config["run_settings"]["exit-on-failure"]) {
106+
process.exit(1);
107+
}
108+
});
93109
}
94110
})
95111
.catch(function (err) {

commands/utils/batch/batch_runner.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ async function run(lt_config, batches, env, i = 0) {
115115
console.log("Waiting for build to finish...");
116116
poller
117117
.poll_build(lt_config, session_id, env)
118-
.then(function () {
119-
resolve();
118+
.then(function (exit_code) {
119+
resolve(exit_code);
120120
})
121121
.catch(function (err) {
122122
console.log();
123123
});
124124
} else {
125-
resolve();
125+
resolve(0);
126126
}
127127
})
128128
.catch(function (err) {

commands/utils/poller/poller.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,18 @@ function poll_build(lt_config, session_id, env) {
3030
} else [(stats[build_info["data"][i]["status_ind"]] = 1)];
3131
}
3232
console.log(stats);
33-
resolve();
33+
if (
34+
Object.keys(stats).length == 1 &&
35+
Object.keys(stats).includes("completed")
36+
) {
37+
resolve(0);
38+
} else {
39+
resolve(1);
40+
}
3441
});
3542
} else {
3643
console.log(err);
37-
resolve();
44+
resolve(1);
3845
}
3946
}
4047
);

commands/utils/set_args.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,13 @@ function sync_args_from_cmd(args) {
235235
}
236236
if ("sync" in args) {
237237
lt_config["run_settings"]["sync"] = true ? args["sync"] == "true" : false;
238+
if ("exit-on-failure" in args) {
239+
lt_config["run_settings"]["exit-on-failure"] = true;
240+
} else {
241+
lt_config["run_settings"]["exit-on-failure"] = false;
242+
}
238243
}
244+
239245
if ("autostart" in args) {
240246
lt_config["tunnel_settings"]["autostart"] = true
241247
? args["autostart"] == "true"

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ const argv = require("yargs")
9898
describe: "Capture Network logs",
9999
type: "string",
100100
})
101+
.option("eof", {
102+
alias: "exit-on-failure",
103+
describe: "Exit With Code 1 on failure",
104+
type: "string",
105+
})
101106
);
102107
},
103108
function (argv) {

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": "2.1.0",
3+
"version": "2.1.1",
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 <[email protected]>",

0 commit comments

Comments
 (0)