Skip to content

Commit d29228c

Browse files
authored
Merge pull request #95 from japneetlambdatest/MLE-3865
Private Repo support and lambdatest_run file support
2 parents 74d3b8c + 4fa22e3 commit d29228c

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

commands/utils/archive.js

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ function archive_project(lt_config) {
3838

3939
archive.on("error", function (err) {
4040
console.log("ERROR", err);
41-
throw err;
41+
reject(err);
42+
//throw err;
4243
});
4344

4445
// pipe archive data to the file
@@ -68,7 +69,7 @@ function archive_project(lt_config) {
6869
console.log("Ignoring files: ", ignore_files);
6970
archive.glob(
7071
"**/*",
71-
{ cwd: process.cwd(), ignore: ignore_files },
72+
{ cwd: process.cwd(), ignore: ignore_files, dot: true },
7273
{ prefix: "project/" }
7374
);
7475
//OverRide NPM Dependencies
@@ -88,6 +89,44 @@ function archive_project(lt_config) {
8889
},
8990
{ prefix: "project/" }
9091
);
92+
if (
93+
lt_config.run_settings.dep_tokens &&
94+
lt_config.run_settings.dep_tokens.length > 0
95+
) {
96+
if (fs.existsSync(".npmrc")) {
97+
let raw_data = fs.readFileSync(".npmrc", "utf8");
98+
let replace_map = {};
99+
for (let i = 0; i < lt_config.run_settings.dep_tokens.length; i++) {
100+
if (process.env[lt_config.run_settings.dep_tokens[i]]) {
101+
//Used for creating regular expression by escaping the $ and {}
102+
replace_map[
103+
"\\$\\{" + lt_config.run_settings.dep_tokens[i] + "\\}"
104+
] = process.env[lt_config.run_settings.dep_tokens[i]];
105+
//User for String replacement
106+
replace_map["${" + lt_config.run_settings.dep_tokens[i] + "}"] =
107+
process.env[lt_config.run_settings.dep_tokens[i]];
108+
} else {
109+
reject("Dep Tokens are not in environment");
110+
return;
111+
}
112+
}
113+
var re = new RegExp(Object.keys(replace_map).join("|"), "gi");
114+
raw_data = raw_data.replace(re, function (matched) {
115+
return replace_map[matched];
116+
});
117+
archive.append(
118+
raw_data,
119+
{
120+
name: "project/.npmrc",
121+
cwd: process.cwd(),
122+
ignore: ignore_files,
123+
},
124+
{ prefix: "project/" }
125+
);
126+
} else {
127+
reject("Dep Tokens are passed but .npmrc does not exist");
128+
}
129+
91130
}
92131

93132
archive.finalize();

commands/utils/batch/batch_runner.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ function run_test(payload, env = "prod") {
5252
if (parseInt(build_id) == 0) {
5353
reject("Some Error occured on Lambdatest Server");
5454
} else {
55+
//Write session_id to a file
56+
data = { build_id: build_id, session_id: session_id };
57+
fs.writeFileSync(
58+
"lambdatest_run.json",
59+
JSON.stringify(data, null, 3)
60+
);
5561
console.log(
5662
`Uploaded tests successfully `,
5763
responseData["value"]["message"]

0 commit comments

Comments
 (0)