Bug 1451911 - Publish action argument schemas as JSON r?rhelmer
MozReview-Commit-ID: 8tMyX1PdseV
new file mode 100755
--- /dev/null
+++ b/toolkit/components/normandy/actions/schemas/export_json.js
@@ -0,0 +1,16 @@
+#!/usr/bin/env node
+/* eslint-env node */
+
+/**
+ * This script exports the schemas from this package in JSON format, for use by
+ * other tools. It is run as a part of the publishing process to NPM.
+ */
+
+const fs = require("fs");
+const schemas = require("./index.js");
+
+fs.writeFile("./schemas.json", JSON.stringify(schemas), err => {
+ if (err) {
+ console.error("error", err);
+ }
+});
--- a/toolkit/components/normandy/actions/schemas/index.js
+++ b/toolkit/components/normandy/actions/schemas/index.js
@@ -13,11 +13,12 @@ const ActionSchemas = {
"description": "Message to log to the console",
"type": "string",
"default": ""
}
}
}
};
-if (this.exports) {
- this.exports = ActionSchemas;
+if (typeof module !== "undefined") {
+ /* globals module */
+ module.exports = ActionSchemas;
}
--- a/toolkit/components/normandy/actions/schemas/package.json
+++ b/toolkit/components/normandy/actions/schemas/package.json
@@ -1,8 +1,11 @@
{
"name": "mozilla-normandy-action-argument-schemas",
- "version": "0.1.0",
+ "version": "0.2.0",
"description": "Schemas for Normandy action arguments",
"main": "index.js",
"author": "Michael Cooper <mcooper@mozilla.com>",
- "license": "MPL-2.0"
+ "license": "MPL-2.0",
+ "scripts": {
+ "prepack": "node export_json.js"
+ }
}