Skip to content

Commit bef58f5

Browse files
committed
correct logic for cypress settings
1 parent 87074d8 commit bef58f5

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

commands/utils/utils.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function split_at_pattern(s, pattern) {
2+
const res = [];
3+
let beg = 0;
4+
let inString = false;
5+
6+
for (let i = 0; i < s.length; i++) {
7+
if (s[i] === pattern && !inString) {
8+
res.push(s.substring(beg, i));
9+
beg = i + 1;
10+
} else if (s[i] === '"') {
11+
if (!inString) {
12+
inString = true;
13+
} else if (i > 0 && s[i - 1] !== '\\') {
14+
inString = false;
15+
}
16+
}
17+
}
18+
19+
res.push(s.substring(beg));
20+
return res;
21+
}
22+
23+
24+
module.exports = {
25+
split_at_pattern: split_at_pattern,
26+
};
27+

commands/utils/validate.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require("fs");
22
const semver = require("semver");
33
const semverCompare = require("semver/functions/compare");
4+
const { split_at_pattern } = require("./utils.js");
45

56
const constants = require("./constants.js");
67
module.exports = validate_config = function (lt_config, validation_configs) {
@@ -208,18 +209,18 @@ module.exports = validate_config = function (lt_config, validation_configs) {
208209
validation_configs.blacklistCommands[i]
209210
);
210211
}
211-
let settings = lt_config["run_settings"]["cypress_settings"].split(";");
212-
//let setting_names = [];
212+
let settings = split_at_pattern(lt_config["run_settings"]["cypress_settings"], ';')
213213
let settings_flag = true;
214214
let setting_param = "";
215215
for (let i = 0; i < settings.length; i++) {
216+
let configs = split_at_pattern(settings[i],' ')
216217
if (
217218
validation_configs.blacklistCommands.some((rx) =>
218-
rx.test(settings[i].split(" ")[0])
219+
rx.test(configs[0])
219220
)
220221
) {
221222
settings_flag = false;
222-
setting_param = settings[i].split(" ")[0];
223+
setting_param = configs[0];
223224
break;
224225
}
225226
}

0 commit comments

Comments
 (0)