summaryrefslogtreecommitdiffstats
path: root/toolkit/components/normandy/metadata-script.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /toolkit/components/normandy/metadata-script.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/normandy/metadata-script.js')
-rw-r--r--toolkit/components/normandy/metadata-script.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/toolkit/components/normandy/metadata-script.js b/toolkit/components/normandy/metadata-script.js
new file mode 100644
index 0000000000..235c8b7a6a
--- /dev/null
+++ b/toolkit/components/normandy/metadata-script.js
@@ -0,0 +1,64 @@
+/* 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/. */
+
+/* eslint-env xpcshell */
+/* globals print, quit, arguments */
+const { RecipeRunner } = ChromeUtils.import(
+ "resource://normandy/lib/RecipeRunner.jsm"
+);
+
+if (arguments.length !== 1) {
+ print("Usage: capabilities-script.js OUTFILE");
+ quit(1);
+}
+
+main(...arguments);
+
+function resolvePath(path) {
+ let absPath = path;
+
+ if (Services.appinfo.OS === "WINNT") {
+ absPath = path = path.replace(/\//g, "\\");
+ }
+
+ if (!PathUtils.isAbsolute(path)) {
+ absPath = Services.dirsvc.get("CurWorkD", Ci.nsIFile).path;
+
+ const components = PathUtils.splitRelative(path, {
+ allowEmpty: true,
+ allowParentDir: true,
+ allowCurrentDir: true,
+ }).filter(c => c.length);
+
+ for (const component of components) {
+ switch (component) {
+ case ".":
+ break;
+
+ case "..":
+ absPath = PathUtils.parent(absPath);
+ break;
+
+ default:
+ absPath = PathUtils.join(absPath, component);
+ }
+ }
+ }
+
+ return absPath;
+}
+
+async function main(outPath) {
+ const capabililitySet = RecipeRunner.getCapabilities();
+ await IOUtils.writeUTF8(
+ resolvePath(outPath),
+ JSON.stringify(
+ {
+ capabilities: Array.from(capabililitySet),
+ },
+ null,
+ 4
+ )
+ );
+}