No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

parseBoltRules.js 1.0KB

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.parseBoltRules = void 0;
  4. const fs = require("fs");
  5. const spawn = require("cross-spawn");
  6. const clc = require("colorette");
  7. const _ = require("lodash");
  8. const error_1 = require("./error");
  9. function parseBoltRules(filename) {
  10. const ruleSrc = fs.readFileSync(filename, "utf8");
  11. const result = spawn.sync("npx", ["--no-install", "firebase-bolt"], {
  12. input: ruleSrc,
  13. timeout: 10000,
  14. encoding: "utf-8",
  15. });
  16. if (result.error && _.get(result.error, "code") === "ENOENT") {
  17. throw new error_1.FirebaseError("Bolt not installed, run " + clc.bold("npm install -g firebase-bolt"));
  18. }
  19. else if (result.error) {
  20. throw new error_1.FirebaseError("Unexpected error parsing Bolt rules file", {
  21. exit: 2,
  22. });
  23. }
  24. else if (result.status != null && result.status > 0) {
  25. throw new error_1.FirebaseError(result.stderr.toString(), { exit: 1 });
  26. }
  27. return result.stdout;
  28. }
  29. exports.parseBoltRules = parseBoltRules;