fs.js 929 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. /**
  4. * @license
  5. * Copyright Google Inc. All Rights Reserved.
  6. *
  7. * Use of this source code is governed by an MIT-style license that can be
  8. * found in the LICENSE file at https://angular.io/license
  9. */
  10. const fs_1 = require("fs");
  11. function isFile(filePath) {
  12. let stat;
  13. try {
  14. stat = fs_1.statSync(filePath);
  15. }
  16. catch (e) {
  17. if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) {
  18. return false;
  19. }
  20. throw e;
  21. }
  22. return stat.isFile() || stat.isFIFO();
  23. }
  24. exports.isFile = isFile;
  25. function isDirectory(filePath) {
  26. let stat;
  27. try {
  28. stat = fs_1.statSync(filePath);
  29. }
  30. catch (e) {
  31. if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) {
  32. return false;
  33. }
  34. throw e;
  35. }
  36. return stat.isDirectory();
  37. }
  38. exports.isDirectory = isDirectory;