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 975B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. mode: [ "string", "null" ],
  34. },
  35. },
  36. process: {
  37. count: "many",
  38. props: {
  39. name: "string",
  40. run: "array",
  41. "in": [ "string", "null" ],
  42. env: [ "object", "null" ],
  43. restart: "bool",
  44. as: [ "string", "null" ],
  45. delay: [ "number", "null" ],
  46. },
  47. },
  48. }
  49. function parse(file) {
  50. try {
  51. return hconfig.parseConfFile(
  52. file, configStructure);
  53. } catch (err) {
  54. if (err.hconfigParseError) {
  55. console.error(err.message);
  56. process.exit(1);
  57. } else {
  58. throw err;
  59. }
  60. }
  61. }