Skip to content

Instantly share code, notes, and snippets.

@foolip
Created February 7, 2019 12:50
Show Gist options
  • Save foolip/fb7cd495510bf7f1a7083c64dd94df08 to your computer and use it in GitHub Desktop.
Save foolip/fb7cd495510bf7f1a7083c64dd94df08 to your computer and use it in GitHub Desktop.
From 515087c9e83140415de8af813270ecc5d8874a17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= <philip@foolip.org>
Date: Thu, 7 Feb 2019 13:49:44 +0100
Subject: [PATCH] Let lint write missing data
---
test/test-browsers.js | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/test/test-browsers.js b/test/test-browsers.js
index 5b23dbdf..770c1db8 100644
--- a/test/test-browsers.js
+++ b/test/test-browsers.js
@@ -1,4 +1,5 @@
'use strict';
+const fs = require('fs');
const path = require('path');
/** @type {Record<string, string[]>} */
@@ -56,7 +57,15 @@ function processData(data, displayBrowsers, requiredBrowsers, category, logger,
}
const missingEntries = requiredBrowsers.filter(value => !(value in data.__compat.support));
if (missingEntries.length > 0) {
- logger.error(`'${path}' is missing the following browsers, which are required for ${category} compat data: ${missingEntries.join(', ')}`);
+ //logger.error(`'${path}' is missing the following browsers, which are required for ${category} compat data: ${missingEntries.join(', ')}`);
+ const origSupport = data.__compat.support;
+ const newSupport = {};
+ const keys = [...Object.keys(origSupport), ...missingEntries];
+ keys.sort();
+ for (const key of keys) {
+ newSupport[key] = key in origSupport ? origSupport[key] : {version_added:null};
+ }
+ data.__compat.support = newSupport;
hasErrors = true;
}
}
@@ -105,9 +114,8 @@ function testBrowsers(filename) {
if (!processData(data, displayBrowsers, requiredBrowsers, category, logger)) {
return false;
} else {
- console.error('\x1b[31m Browsers –', errors.length, 'error(s):\x1b[0m');
- for (let error of errors)
- console.error(` ${error}`);
+ fs.writeFileSync(filename, JSON.stringify(data, null, ' ') + '\n');
+ console.log(`Fixed ${filename}`);
return true;
}
}
--
2.20.1.611.gfbb209baf1-goog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment