Personal intranet/start page where I can view the weather, links, fitbit data, and the news.
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.

35 lines
752 B

5 years ago
5 years ago
  1. const fs = require('fs');
  2. module.exports=
  3. {
  4. /**
  5. *
  6. * @param fileName
  7. * @returns {any}
  8. */
  9. getFileAsJSON: function(fileName)
  10. {
  11. return JSON.parse(module.exports.getFile(fileName));
  12. },
  13. getFile: function(filename)
  14. {
  15. return fs.readFileSync(filename, 'utf8');
  16. },
  17. saveFile: function(filename, contents)
  18. {
  19. fs.writeFile(filename, contents, function(err)
  20. {
  21. if(err)
  22. {
  23. console.log(err);
  24. }
  25. else
  26. {
  27. console.log(filename + " saved");
  28. }
  29. });
  30. }
  31. };