diff --git a/commands/utils/utils.js b/commands/utils/utils.js new file mode 100644 index 0000000..f648403 --- /dev/null +++ b/commands/utils/utils.js @@ -0,0 +1,27 @@ +function split_at_pattern(s, pattern) { + const res = []; + let beg = 0; + let inString = false; + + for (let i = 0; i < s.length; i++) { + if (s[i] === pattern && !inString) { + res.push(s.substring(beg, i)); + beg = i + 1; + } else if (s[i] === '"') { + if (!inString) { + inString = true; + } else if (i > 0 && s[i - 1] !== '\\') { + inString = false; + } + } + } + + res.push(s.substring(beg)); + return res; +} + + +module.exports = { + split_at_pattern: split_at_pattern, + }; + \ No newline at end of file diff --git a/commands/utils/validate.js b/commands/utils/validate.js index 0ae774f..f796664 100644 --- a/commands/utils/validate.js +++ b/commands/utils/validate.js @@ -1,6 +1,7 @@ const fs = require("fs"); const semver = require("semver"); const semverCompare = require("semver/functions/compare"); +const { split_at_pattern } = require("./utils.js"); const constants = require("./constants.js"); module.exports = validate_config = function (lt_config, validation_configs) { @@ -208,18 +209,18 @@ module.exports = validate_config = function (lt_config, validation_configs) { validation_configs.blacklistCommands[i] ); } - let settings = lt_config["run_settings"]["cypress_settings"].split(";"); - //let setting_names = []; + let settings = split_at_pattern(lt_config["run_settings"]["cypress_settings"], ';') let settings_flag = true; let setting_param = ""; for (let i = 0; i < settings.length; i++) { + let configs = split_at_pattern(settings[i],' ') if ( validation_configs.blacklistCommands.some((rx) => - rx.test(settings[i].split(" ")[0]) + rx.test(configs[0]) ) ) { settings_flag = false; - setting_param = settings[i].split(" ")[0]; + setting_param = configs[0]; break; } } diff --git a/package-lock.json b/package-lock.json index 2ccc59a..f2bb82e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lambdatest-cypress-cli", - "version": "3.0.21", + "version": "3.0.22", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "lambdatest-cypress-cli", - "version": "3.0.21", + "version": "3.0.22", "license": "MIT", "dependencies": { "@lambdatest/node-tunnel": "latest", diff --git a/package.json b/package.json index 8fd3a37..dafbca5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lambdatest-cypress-cli", - "version": "3.0.21", + "version": "3.0.22", "description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.", "homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli", "author": "LambdaTest ",