getDirectory.js 900 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getDirectory = getDirectory;
  6. exports.getDirectorySync = getDirectorySync;
  7. var _path = _interopRequireDefault(require("path"));
  8. var _pathType = require("path-type");
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. async function getDirectory(filepath) {
  11. const filePathIsDirectory = await (0, _pathType.isDirectory)(filepath);
  12. if (filePathIsDirectory === true) {
  13. return filepath;
  14. }
  15. const directory = _path.default.dirname(filepath);
  16. return directory;
  17. }
  18. function getDirectorySync(filepath) {
  19. const filePathIsDirectory = (0, _pathType.isDirectorySync)(filepath);
  20. if (filePathIsDirectory === true) {
  21. return filepath;
  22. }
  23. const directory = _path.default.dirname(filepath);
  24. return directory;
  25. }
  26. //# sourceMappingURL=getDirectory.js.map