@devicecloud.dev/dcd 2.1.0 → 2.1.1

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.
@@ -35,25 +35,40 @@ function isFlowFile(filePath) {
35
35
  return filePath.endsWith('.yaml') || filePath.endsWith('.yml');
36
36
  }
37
37
  const readYamlFileAsJson = (filePath) => {
38
- const yamlText = fs.readFileSync(filePath, 'utf8');
39
- return yaml.load(yamlText);
38
+ try {
39
+ const yamlText = fs.readFileSync(filePath, 'utf8');
40
+ return yaml.load(yamlText);
41
+ }
42
+ catch (error) {
43
+ const message = `Error parsing YAML file ${filePath}: ${error}`;
44
+ console.error(message);
45
+ throw new Error(message);
46
+ }
40
47
  };
41
48
  exports.readYamlFileAsJson = readYamlFileAsJson;
42
49
  const readTestYamlFileAsJson = (filePath) => {
43
- const yamlText = fs.readFileSync(filePath, 'utf8');
44
- if (yamlText.includes('\n---\n')) {
45
- const yamlTexts = yamlText.split('\n---\n');
46
- const config = yaml.load(yamlTexts[0]);
47
- const testSteps = yaml.load(yamlTexts[1]);
48
- if (Object.keys(config ?? {}).length > 0) {
49
- return { config, testSteps };
50
+ try {
51
+ const yamlText = fs.readFileSync(filePath, 'utf8');
52
+ const normalizedText = yamlText.replaceAll('\r\n', '\n');
53
+ if (normalizedText.includes('\n---\n')) {
54
+ const yamlTexts = normalizedText.split('\n---\n');
55
+ const config = yaml.load(yamlTexts[0]);
56
+ const testSteps = yaml.load(yamlTexts[1]);
57
+ if (Object.keys(config ?? {}).length > 0) {
58
+ return { config, testSteps };
59
+ }
60
+ }
61
+ const testSteps = yaml.load(yamlText);
62
+ if (Object.keys(testSteps).length > 0) {
63
+ return { config: null, testSteps };
50
64
  }
51
- }
52
- const testSteps = yaml.load(yamlText);
53
- if (Object.keys(testSteps).length > 0) {
54
65
  return { config: null, testSteps };
55
66
  }
56
- return { config: null, testSteps };
67
+ catch (error) {
68
+ const message = `Error parsing YAML file ${filePath}: ${error}`;
69
+ console.error(message);
70
+ throw new Error(message);
71
+ }
57
72
  };
58
73
  exports.readTestYamlFileAsJson = readTestYamlFileAsJson;
59
74
  async function readDirectory(dir, filterFunction) {
@@ -287,5 +287,5 @@
287
287
  ]
288
288
  }
289
289
  },
290
- "version": "2.1.0"
290
+ "version": "2.1.1"
291
291
  }
package/package.json CHANGED
@@ -80,7 +80,7 @@
80
80
  "test": "mocha --forbid-only \"test/**/*.test.ts\"",
81
81
  "version": "oclif readme && git add README.md"
82
82
  },
83
- "version": "2.1.0",
83
+ "version": "2.1.1",
84
84
  "bugs": {
85
85
  "url": "https://discord.gg/gm3mJwcNw8"
86
86
  },