diffpx 0.0.9 → 0.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffpx",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "bin": {
5
5
  "diffpx": "bin/diffpx.js"
6
6
  },
package/src/upload.js CHANGED
@@ -8,11 +8,14 @@ function axiosErrorMessage(err) {
8
8
  const statusText = err?.response?.statusText;
9
9
 
10
10
  const data = err?.response?.data;
11
+ const jsonMsg = data && typeof data === 'object'
12
+ ? String(data.error || data.message || '').trim()
13
+ : '';
11
14
  const body = typeof data === 'string'
12
15
  ? ((data.match(/<pre>([\s\S]*?)<\/pre>/i)?.[1] || data).replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim())
13
16
  : '';
14
17
 
15
- return [status ? `HTTP ${status}${statusText ? ` ${statusText}` : ''}` : '', body || '']
18
+ return [status ? `HTTP ${status}${statusText ? ` ${statusText}` : ''}` : '', jsonMsg || body || '']
16
19
  .filter(Boolean)
17
20
  .join(' | ');
18
21
  }
@@ -32,8 +32,11 @@ async function validateConfig() {
32
32
  process.exit(1);
33
33
  }
34
34
 
35
- const config = yaml.load(fs.readFileSync('snapshots.yml', 'utf8'));
36
- const devicesList = yaml.load(fs.readFileSync('devices.yml', 'utf8'));
35
+ const rawConfig = yaml.load(fs.readFileSync('snapshots.yml', 'utf8'));
36
+ const rawDevices = yaml.load(fs.readFileSync('devices.yml', 'utf8'));
37
+
38
+ const config = Array.isArray(rawConfig) ? rawConfig : [];
39
+ const devicesList = Array.isArray(rawDevices) ? rawDevices : [];
37
40
 
38
41
  const devicesConfig = {};
39
42
  for (const d of devicesList) devicesConfig[d.name] = d;
@@ -41,6 +44,10 @@ async function validateConfig() {
41
44
  const seenNames = new Set();
42
45
  const configErrors = [];
43
46
 
47
+ if (!config.length) {
48
+ configErrors.push('🔴 snapshots.yml must contain at least one snapshot');
49
+ }
50
+
44
51
  for (const entry of config) {
45
52
  if (seenNames.has(entry.name)) {
46
53
  configErrors.push(`🔴 Duplicate snapshot name "${ entry.name }" found in snapshots.yml`);