1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.getDirectory = getDirectory;
|
7 | exports.getDirectorySync = getDirectorySync;
|
8 |
|
9 | var _path = _interopRequireDefault(require("path"));
|
10 |
|
11 | var _pathType = require("path-type");
|
12 |
|
13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14 |
|
15 | async 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 |
|
27 | function 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 |
|
\ | No newline at end of file |