Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
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.

47 lines
816 B

  1. 'use strict';
  2. const path = require('path');
  3. const loadJsonFile = require('load-json-file');
  4. const pathType = require('path-type');
  5. module.exports = (fp, opts) => {
  6. if (typeof fp !== 'string') {
  7. opts = fp;
  8. fp = '.';
  9. }
  10. opts = opts || {};
  11. return pathType.dir(fp)
  12. .then(isDir => {
  13. if (isDir) {
  14. fp = path.join(fp, 'package.json');
  15. }
  16. return loadJsonFile(fp);
  17. })
  18. .then(x => {
  19. if (opts.normalize !== false) {
  20. require('normalize-package-data')(x);
  21. }
  22. return x;
  23. });
  24. };
  25. module.exports.sync = (fp, opts) => {
  26. if (typeof fp !== 'string') {
  27. opts = fp;
  28. fp = '.';
  29. }
  30. opts = opts || {};
  31. fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;
  32. const x = loadJsonFile.sync(fp);
  33. if (opts.normalize !== false) {
  34. require('normalize-package-data')(x);
  35. }
  36. return x;
  37. };