Turn audio into a shareable video. forked from nypublicradio/audiogram

index.js 855B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var _ = require("underscore"),
  2. path = require("path"),
  3. fs = require("fs");
  4. var settings = tryToLoad("settings/index.js"),
  5. themes = tryToLoad("settings/themes.json");
  6. // Validate settings
  7. require("./validate-settings.js")(settings);
  8. // Validate themes
  9. require("./validate-themes.js")(themes);
  10. module.exports = settings;
  11. // Try to load modules
  12. function tryToLoad(filename) {
  13. var loaded;
  14. try {
  15. loaded = require(path.join(__dirname, "..", "..", filename));
  16. if (!loaded) {
  17. throw new Error("Couldn't load contents of " + filename + ".");
  18. }
  19. } catch(e) {
  20. if (e.code === "MODULE_NOT_FOUND") {
  21. throw new Error("No " + filename + " file found.");
  22. } else if (e instanceof SyntaxError) {
  23. console.warn("Error parsing " + filename);
  24. throw e;
  25. } else {
  26. throw e;
  27. }
  28. }
  29. return loaded;
  30. }