testdriverai 4.2.11 → 4.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent.js +43 -41
- package/package.json +1 -1
package/agent.js
CHANGED
|
@@ -453,6 +453,46 @@ const aiExecute = async (message, validateAndLoop = false) => {
|
|
|
453
453
|
}
|
|
454
454
|
};
|
|
455
455
|
|
|
456
|
+
const loadYML = async (file) => {
|
|
457
|
+
|
|
458
|
+
let yml;
|
|
459
|
+
|
|
460
|
+
//wrap this in try/catch so if the file doesn't exist output an error message to the user
|
|
461
|
+
try {
|
|
462
|
+
yml = fs.readFileSync(file, "utf-8");
|
|
463
|
+
} catch (e) {
|
|
464
|
+
logger.error(e);
|
|
465
|
+
logger.error(`File not found: ${file}`);
|
|
466
|
+
logger.error(`Current directory: ${process.cwd()}`);
|
|
467
|
+
|
|
468
|
+
await summarize("File not found");
|
|
469
|
+
await exit(true);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
let interpolationVars = JSON.parse(process.env["TD_INTERPOLATION_VARS"] || '{}');
|
|
473
|
+
|
|
474
|
+
// Inject environment variables into any ${VAR} strings
|
|
475
|
+
yml = parser.interpolate(yml, process.env);
|
|
476
|
+
|
|
477
|
+
// Inject any vars from the TD_INTERPOLATION_VARS variable (typically from the action)
|
|
478
|
+
yml = parser.interpolate(yml, interpolationVars);
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
let ymlObj = null;
|
|
482
|
+
try {
|
|
483
|
+
ymlObj = await yaml.load(yml);
|
|
484
|
+
} catch (e) {
|
|
485
|
+
logger.error("%s", e);
|
|
486
|
+
logger.error(`Invalid YAML: ${file}`);
|
|
487
|
+
|
|
488
|
+
await summarize("Invalid YAML");
|
|
489
|
+
await exit(true);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
return ymlObj;
|
|
493
|
+
|
|
494
|
+
}
|
|
495
|
+
|
|
456
496
|
const assert = async (expect) => {
|
|
457
497
|
analytics.track("assert");
|
|
458
498
|
|
|
@@ -893,40 +933,7 @@ let run = async (file, shouldSave = false, shouldExit = true) => {
|
|
|
893
933
|
|
|
894
934
|
logger.info(chalk.cyan(`running ${file}...`));
|
|
895
935
|
|
|
896
|
-
|
|
897
|
-
let yml;
|
|
898
|
-
|
|
899
|
-
//wrap this in try/catch so if the file doesn't exist output an error message to the user
|
|
900
|
-
try {
|
|
901
|
-
yml = fs.readFileSync(file, "utf-8");
|
|
902
|
-
} catch (e) {
|
|
903
|
-
logger.error(e);
|
|
904
|
-
logger.error(`File not found: ${file}`);
|
|
905
|
-
logger.error(`Current directory: ${process.cwd()}`);
|
|
906
|
-
|
|
907
|
-
await summarize("File not found");
|
|
908
|
-
await exit(true);
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
let interpolationVars = JSON.parse(process.env["TD_INTERPOLATION_VARS"] || '{}');
|
|
912
|
-
|
|
913
|
-
// Inject environment variables into any ${VAR} strings
|
|
914
|
-
yml = parser.interpolate(yml, process.env);
|
|
915
|
-
|
|
916
|
-
// Inject any vars from the TD_INTERPOLATION_VARS variable (typically from the action)
|
|
917
|
-
yml = parser.interpolate(yml, interpolationVars);
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
let ymlObj = null;
|
|
921
|
-
try {
|
|
922
|
-
ymlObj = await yaml.load(yml);
|
|
923
|
-
} catch (e) {
|
|
924
|
-
logger.error("%s", e);
|
|
925
|
-
logger.error(`Invalid YAML: ${file}`);
|
|
926
|
-
|
|
927
|
-
await summarize("Invalid YAML");
|
|
928
|
-
await exit(true);
|
|
929
|
-
}
|
|
936
|
+
let ymlObj = await loadYML(file);
|
|
930
937
|
|
|
931
938
|
if (ymlObj.version) {
|
|
932
939
|
let valid = isValidVersion(ymlObj.version);
|
|
@@ -1027,14 +1034,9 @@ const embed = async (file, depth) => {
|
|
|
1027
1034
|
throw `Embedded file not found: ${file}`;
|
|
1028
1035
|
}
|
|
1029
1036
|
|
|
1030
|
-
|
|
1031
|
-
let contents = fs.readFileSync(file, "utf8");
|
|
1037
|
+
let ymlObj = await loadYML(file);
|
|
1032
1038
|
|
|
1033
|
-
|
|
1034
|
-
let steps = yaml.load(contents).steps;
|
|
1035
|
-
// for each step, execute the commands
|
|
1036
|
-
|
|
1037
|
-
for (const step of steps) {
|
|
1039
|
+
for (const step of ymlObj.steps) {
|
|
1038
1040
|
await executeCommands(step.commands, depth);
|
|
1039
1041
|
}
|
|
1040
1042
|
|