filesystem.js 717 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2017 Lovell Fuller and others.
  2. // SPDX-License-Identifier: Apache-2.0
  3. 'use strict';
  4. const fs = require('fs');
  5. /**
  6. * The path where we can find the ldd
  7. */
  8. const LDD_PATH = '/usr/bin/ldd';
  9. /**
  10. * Read the content of a file synchronous
  11. *
  12. * @param {string} path
  13. * @returns {string}
  14. */
  15. const readFileSync = (path) => fs.readFileSync(path, 'utf-8');
  16. /**
  17. * Read the content of a file
  18. *
  19. * @param {string} path
  20. * @returns {Promise<string>}
  21. */
  22. const readFile = (path) => new Promise((resolve, reject) => {
  23. fs.readFile(path, 'utf-8', (err, data) => {
  24. if (err) {
  25. reject(err);
  26. } else {
  27. resolve(data);
  28. }
  29. });
  30. });
  31. module.exports = {
  32. LDD_PATH,
  33. readFileSync,
  34. readFile
  35. };