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.

parse-conf.js 944B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var hconfig = require("hconfig");
  2. module.exports = parse;
  3. var configStructure = {
  4. general: {
  5. count: "once",
  6. props: {
  7. log: "string",
  8. },
  9. },
  10. display: {
  11. count: "many",
  12. props: {
  13. name: "string",
  14. mode: "string",
  15. rate: "string",
  16. where: "object",
  17. },
  18. },
  19. input: {
  20. count: "many",
  21. props: {
  22. name: "string",
  23. type: "string",
  24. commands: "array",
  25. options: "array",
  26. },
  27. },
  28. wallpaper: {
  29. count: "once",
  30. props: {
  31. name: "null",
  32. path: "string",
  33. },
  34. },
  35. process: {
  36. count: "many",
  37. props: {
  38. name: "string",
  39. run: "array",
  40. "in": [ "string", "null" ],
  41. env: [ "object", "null" ],
  42. restart: "bool",
  43. as: [ "string", "null" ],
  44. delay: [ "number", "null" ],
  45. },
  46. },
  47. }
  48. function parse(file) {
  49. try {
  50. return hconfig.parseConfFile(
  51. file, configStructure);
  52. } catch (err) {
  53. if (err.hconfigParseError) {
  54. console.error(err.message);
  55. process.exit(1);
  56. } else {
  57. throw err;
  58. }
  59. }
  60. }