UNPKG

900 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.getDirectory = getDirectory;
7exports.getDirectorySync = getDirectorySync;
8
9var _path = _interopRequireDefault(require("path"));
10
11var _pathType = require("path-type");
12
13function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15async function getDirectory(filepath) {
16 const filePathIsDirectory = await (0, _pathType.isDirectory)(filepath);
17
18 if (filePathIsDirectory === true) {
19 return filepath;
20 }
21
22 const directory = _path.default.dirname(filepath);
23
24 return directory;
25}
26
27function getDirectorySync(filepath) {
28 const filePathIsDirectory = (0, _pathType.isDirectorySync)(filepath);
29
30 if (filePathIsDirectory === true) {
31 return filepath;
32 }
33
34 const directory = _path.default.dirname(filepath);
35
36 return directory;
37}
38//# sourceMappingURL=getDirectory.js.map
\No newline at end of file