summaryrefslogtreecommitdiffstats
path: root/tools/lint/eslint/eslint-plugin-mozilla/scripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /tools/lint/eslint/eslint-plugin-mozilla/scripts
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/scripts/createExports.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/scripts/createExports.js b/tools/lint/eslint/eslint-plugin-mozilla/scripts/createExports.js
new file mode 100644
index 0000000000..7f839edfba
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/scripts/createExports.js
@@ -0,0 +1,77 @@
+/**
+ * @fileoverview A script to export the known globals to a file.
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+"use strict";
+
+var fs = require("fs");
+var path = require("path");
+var helpers = require("../lib/helpers");
+
+const eslintDir = path.join(helpers.rootDir, "tools", "lint", "eslint");
+
+const globalsFile = path.join(
+ eslintDir,
+ "eslint-plugin-mozilla",
+ "lib",
+ "environments",
+ "saved-globals.json"
+);
+const rulesFile = path.join(
+ eslintDir,
+ "eslint-plugin-mozilla",
+ "lib",
+ "rules",
+ "saved-rules-data.json"
+);
+
+console.log("Copying services.json");
+
+const env = helpers.getBuildEnvironment();
+
+const servicesFile = path.join(
+ env.topobjdir,
+ "xpcom",
+ "components",
+ "services.json"
+);
+const shipServicesFile = path.join(
+ eslintDir,
+ "eslint-plugin-mozilla",
+ "lib",
+ "services.json"
+);
+
+fs.writeFileSync(shipServicesFile, fs.readFileSync(servicesFile));
+
+console.log("Generating globals file");
+
+// Export the environments.
+let environmentGlobals = require("../lib/index.js").environments;
+
+return fs.writeFile(
+ globalsFile,
+ JSON.stringify({ environments: environmentGlobals }),
+ err => {
+ if (err) {
+ console.error(err);
+ process.exit(1);
+ }
+
+ console.log("Globals file generation complete");
+
+ console.log("Creating rules data file");
+ let rulesData = {};
+
+ return fs.writeFile(rulesFile, JSON.stringify({ rulesData }), err1 => {
+ if (err1) {
+ console.error(err1);
+ process.exit(1);
+ }
+
+ console.log("Globals file generation complete");
+ });
+ }
+);