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

load.js 560B

123456789101112131415161718192021222324252627
  1. var path = require("path");
  2. // Try to load module
  3. module.exports = function(filename) {
  4. var loaded;
  5. try {
  6. loaded = require(path.join(__dirname, "..", "..", filename));
  7. if (!loaded) {
  8. throw new Error("Couldn't load contents of " + filename + ".");
  9. }
  10. } catch(e) {
  11. if (e.code === "MODULE_NOT_FOUND") {
  12. throw new Error("No " + filename + " file found.");
  13. } else if (e instanceof SyntaxError) {
  14. console.warn("Error parsing " + filename + ".");
  15. throw e;
  16. } else {
  17. throw e;
  18. }
  19. }
  20. return loaded;
  21. }