@bemoje/path 0.1.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +121 -0
- package/index.mjs +153 -0
- package/package.json +22 -18
- package/LICENSE +0 -21
- package/README.md +0 -34
- package/cjs/index.d.ts +0 -25
- package/cjs/index.d.ts.map +0 -1
- package/cjs/index.js +0 -28
- package/cjs/index.js.map +0 -1
- package/cjs/lib/createFileExtensionFilter.d.ts +0 -14
- package/cjs/lib/createFileExtensionFilter.d.ts.map +0 -1
- package/cjs/lib/createFileExtensionFilter.js +0 -27
- package/cjs/lib/createFileExtensionFilter.js.map +0 -1
- package/cjs/lib/cwdpath.d.ts +0 -13
- package/cjs/lib/cwdpath.d.ts.map +0 -1
- package/cjs/lib/cwdpath.js +0 -21
- package/cjs/lib/cwdpath.js.map +0 -1
- package/cjs/lib/getAppDataPath.d.ts +0 -5
- package/cjs/lib/getAppDataPath.d.ts.map +0 -1
- package/cjs/lib/getAppDataPath.js +0 -37
- package/cjs/lib/getAppDataPath.js.map +0 -1
- package/cjs/lib/getDiskDrivesWindows.d.ts +0 -10
- package/cjs/lib/getDiskDrivesWindows.d.ts.map +0 -1
- package/cjs/lib/getDiskDrivesWindows.js +0 -24
- package/cjs/lib/getDiskDrivesWindows.js.map +0 -1
- package/cjs/lib/getDownloadsDirectory.d.ts +0 -12
- package/cjs/lib/getDownloadsDirectory.d.ts.map +0 -1
- package/cjs/lib/getDownloadsDirectory.js +0 -52
- package/cjs/lib/getDownloadsDirectory.js.map +0 -1
- package/cjs/lib/getHomeDirectory.d.ts +0 -5
- package/cjs/lib/getHomeDirectory.d.ts.map +0 -1
- package/cjs/lib/getHomeDirectory.js +0 -16
- package/cjs/lib/getHomeDirectory.js.map +0 -1
- package/cjs/lib/getTempDataPath.d.ts +0 -7
- package/cjs/lib/getTempDataPath.d.ts.map +0 -1
- package/cjs/lib/getTempDataPath.js +0 -18
- package/cjs/lib/getTempDataPath.js.map +0 -1
- package/cjs/lib/isValidFileExtension.d.ts +0 -7
- package/cjs/lib/isValidFileExtension.d.ts.map +0 -1
- package/cjs/lib/isValidFileExtension.js +0 -13
- package/cjs/lib/isValidFileExtension.js.map +0 -1
- package/cjs/lib/isValidWindowsPath.d.ts +0 -10
- package/cjs/lib/isValidWindowsPath.d.ts.map +0 -1
- package/cjs/lib/isValidWindowsPath.js +0 -26
- package/cjs/lib/isValidWindowsPath.js.map +0 -1
- package/cjs/lib/normalizeFileExtension.d.ts +0 -23
- package/cjs/lib/normalizeFileExtension.d.ts.map +0 -1
- package/cjs/lib/normalizeFileExtension.js +0 -34
- package/cjs/lib/normalizeFileExtension.js.map +0 -1
- package/cjs/lib/pathAbsoluteToRelativeCwd.d.ts +0 -14
- package/cjs/lib/pathAbsoluteToRelativeCwd.d.ts.map +0 -1
- package/cjs/lib/pathAbsoluteToRelativeCwd.js +0 -28
- package/cjs/lib/pathAbsoluteToRelativeCwd.js.map +0 -1
- package/cjs/lib/pathBasename.d.ts +0 -19
- package/cjs/lib/pathBasename.d.ts.map +0 -1
- package/cjs/lib/pathBasename.js +0 -43
- package/cjs/lib/pathBasename.js.map +0 -1
- package/cjs/lib/pathDirname.d.ts +0 -19
- package/cjs/lib/pathDirname.d.ts.map +0 -1
- package/cjs/lib/pathDirname.js +0 -48
- package/cjs/lib/pathDirname.js.map +0 -1
- package/cjs/lib/pathExtname.d.ts +0 -14
- package/cjs/lib/pathExtname.d.ts.map +0 -1
- package/cjs/lib/pathExtname.js +0 -39
- package/cjs/lib/pathExtname.js.map +0 -1
- package/cjs/lib/pathGetSeparator.d.ts +0 -8
- package/cjs/lib/pathGetSeparator.d.ts.map +0 -1
- package/cjs/lib/pathGetSeparator.js +0 -19
- package/cjs/lib/pathGetSeparator.js.map +0 -1
- package/cjs/lib/pathIsAbsolute.d.ts +0 -19
- package/cjs/lib/pathIsAbsolute.d.ts.map +0 -1
- package/cjs/lib/pathIsAbsolute.js +0 -30
- package/cjs/lib/pathIsAbsolute.js.map +0 -1
- package/cjs/lib/pathIsDotFile.d.ts +0 -7
- package/cjs/lib/pathIsDotFile.d.ts.map +0 -1
- package/cjs/lib/pathIsDotFile.js +0 -13
- package/cjs/lib/pathIsDotFile.js.map +0 -1
- package/cjs/lib/pathIsRelative.d.ts +0 -7
- package/cjs/lib/pathIsRelative.d.ts.map +0 -1
- package/cjs/lib/pathIsRelative.js +0 -13
- package/cjs/lib/pathIsRelative.js.map +0 -1
- package/cjs/lib/pathIsRelativePosix.d.ts +0 -7
- package/cjs/lib/pathIsRelativePosix.d.ts.map +0 -1
- package/cjs/lib/pathIsRelativePosix.js +0 -13
- package/cjs/lib/pathIsRelativePosix.js.map +0 -1
- package/cjs/lib/pathIsRelativeWindows.d.ts +0 -7
- package/cjs/lib/pathIsRelativeWindows.d.ts.map +0 -1
- package/cjs/lib/pathIsRelativeWindows.js +0 -14
- package/cjs/lib/pathIsRelativeWindows.js.map +0 -1
- package/cjs/lib/pathIsUnc.d.ts +0 -7
- package/cjs/lib/pathIsUnc.d.ts.map +0 -1
- package/cjs/lib/pathIsUnc.js +0 -13
- package/cjs/lib/pathIsUnc.js.map +0 -1
- package/cjs/lib/pathJoin.d.ts +0 -5
- package/cjs/lib/pathJoin.d.ts.map +0 -1
- package/cjs/lib/pathJoin.js +0 -10
- package/cjs/lib/pathJoin.js.map +0 -1
- package/cjs/lib/pathRoot.d.ts +0 -19
- package/cjs/lib/pathRoot.d.ts.map +0 -1
- package/cjs/lib/pathRoot.js +0 -41
- package/cjs/lib/pathRoot.js.map +0 -1
- package/cjs/lib/toPosixPath.d.ts +0 -5
- package/cjs/lib/toPosixPath.d.ts.map +0 -1
- package/cjs/lib/toPosixPath.js +0 -9
- package/cjs/lib/toPosixPath.js.map +0 -1
package/index.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Arrayable } from 'type-fest';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Join paths starting from process.cwd()
|
|
5
|
+
*
|
|
6
|
+
* @example ```ts
|
|
7
|
+
* // equivalent to:
|
|
8
|
+
* path.join(process.cwd(), ...p)
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
declare function cwd(...p: string[]): string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns the absolute path of the parent directory of the given path.
|
|
15
|
+
* @param p the path
|
|
16
|
+
* @param depth how many times to get the parent directory
|
|
17
|
+
* @example dirnameDeep('a/b/c/d', 2) => 'a/b'
|
|
18
|
+
*/
|
|
19
|
+
declare function dirnameDeep(p: string, depth?: number): string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Checks if a file path has any of the specified basenames.
|
|
23
|
+
*/
|
|
24
|
+
declare function hasBasename(tsFilepath: string, basenames: Arrayable<string>): boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a file path has any of the specified file extensions.
|
|
28
|
+
*/
|
|
29
|
+
declare function hasExtname(tsFilepath: string, extnames: Arrayable<string>): boolean;
|
|
30
|
+
declare namespace hasExtname {
|
|
31
|
+
var js: (tsFilepath: string) => boolean;
|
|
32
|
+
var json: (tsFilepath: string) => boolean;
|
|
33
|
+
var yaml: (tsFilepath: string) => boolean;
|
|
34
|
+
var markdown: (tsFilepath: string) => boolean;
|
|
35
|
+
var ts: (tsFilepath: string) => boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Whether fspath is a subpath of a parent directory with the given name.
|
|
40
|
+
*/
|
|
41
|
+
declare function hasParentDirname(fspath: string, name: string): boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Determines if a given filepath is a dotfile.
|
|
45
|
+
* @param filepath - The filepath to evaluate.
|
|
46
|
+
* @returns A boolean indicating whether the filepath is a dotfile.
|
|
47
|
+
*/
|
|
48
|
+
declare function isDotFile(filepath: string): boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Check if a file extension is valid.
|
|
52
|
+
*
|
|
53
|
+
* Invalid:
|
|
54
|
+
* - empty string
|
|
55
|
+
* - single dot: "."
|
|
56
|
+
* - illegal characters: <>"|?*:
|
|
57
|
+
*
|
|
58
|
+
* @param ext - The file extension to check.
|
|
59
|
+
*/
|
|
60
|
+
declare function isExtValid(ext: string): boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Whether a path is a relative string, ie. not absolute.
|
|
64
|
+
*/
|
|
65
|
+
declare function isRelative(p: string): boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Determines if a given filepath is a UNC path.
|
|
69
|
+
* @param filepath - The filepath to evaluate.
|
|
70
|
+
* @returns A boolean indicating whether the filepath is a UNC path.
|
|
71
|
+
*/
|
|
72
|
+
declare function isUnc(filepath: string): boolean;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Check whether a provided windows filesystem path string is valid according to:
|
|
76
|
+
* https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
|
77
|
+
* @param path The path to validate.
|
|
78
|
+
* @throws If the path is invalid and the `assert` option is true.
|
|
79
|
+
*/
|
|
80
|
+
declare function isValidWin32(path: string, options?: {
|
|
81
|
+
extendedMaxLength?: boolean;
|
|
82
|
+
}): boolean;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Append string to the beginning of the filename.
|
|
86
|
+
*
|
|
87
|
+
* @example ```ts
|
|
88
|
+
* path.fileNameWithPrefix('path/to/file-name.ext', 'new-')
|
|
89
|
+
* // => path/to/new-file-name.ext
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function prefixFilename(filePath: string, prefix: string): string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Returns the root directory of a given path.
|
|
96
|
+
*/
|
|
97
|
+
declare function root(p: string): string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Append string to the end of the filename.
|
|
101
|
+
*
|
|
102
|
+
* @example ```ts
|
|
103
|
+
* path.suffixFilename('path/to/file-name.ext', '-old')
|
|
104
|
+
* // => path/to/file-name-old.ext
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare function suffixFilename(filePath: string, suffix: string): string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Solve the relative path from the process.cwd() path to the {p} path.
|
|
111
|
+
* At times we have two absolute paths, and we need to derive the relative path from one to the other.
|
|
112
|
+
* This is actually the reverse transform of path.resolve.
|
|
113
|
+
*/
|
|
114
|
+
declare function toCwdRelative(p: string): string;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Ensures win32 backslashes are used instead of forward slashes.
|
|
118
|
+
*/
|
|
119
|
+
declare function toWin32(p: string): string;
|
|
120
|
+
|
|
121
|
+
export { cwd, dirnameDeep, hasBasename, hasExtname, hasParentDirname, isDotFile, isExtValid, isRelative, isUnc, isValidWin32, prefixFilename, root, suffixFilename, toCwdRelative, toWin32 };
|
package/index.mjs
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import upath4 from 'upath';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
function cwd(...p) {
|
|
7
|
+
return upath4.joinSafe(process.cwd(), ...p);
|
|
8
|
+
}
|
|
9
|
+
__name(cwd, "cwd");
|
|
10
|
+
function dirnameDeep(p, depth) {
|
|
11
|
+
const parent = upath4.dirname(p);
|
|
12
|
+
return depth && depth > 1 ? dirnameDeep(parent, depth - 1) : parent;
|
|
13
|
+
}
|
|
14
|
+
__name(dirnameDeep, "dirnameDeep");
|
|
15
|
+
function hasBasename(tsFilepath, basenames) {
|
|
16
|
+
return [
|
|
17
|
+
basenames
|
|
18
|
+
].flat(2).includes(upath4.basename(tsFilepath));
|
|
19
|
+
}
|
|
20
|
+
__name(hasBasename, "hasBasename");
|
|
21
|
+
|
|
22
|
+
// ../fn/src/preserveNameAndLength.ts
|
|
23
|
+
function preserveNameAndLength(source, target, adjustLengthBy = 0) {
|
|
24
|
+
return Object.defineProperties(target, {
|
|
25
|
+
name: {
|
|
26
|
+
configurable: true,
|
|
27
|
+
value: source.name
|
|
28
|
+
},
|
|
29
|
+
length: {
|
|
30
|
+
configurable: true,
|
|
31
|
+
value: source.length + adjustLengthBy
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
__name(preserveNameAndLength, "preserveNameAndLength");
|
|
36
|
+
|
|
37
|
+
// ../fn/src/bindArg.ts
|
|
38
|
+
function bindArg(fn, boundArgIndex, boundArgValue) {
|
|
39
|
+
return preserveNameAndLength(fn, (...args) => {
|
|
40
|
+
return fn(...args.slice(0, boundArgIndex), boundArgValue, ...args.slice(boundArgIndex));
|
|
41
|
+
}, -1);
|
|
42
|
+
}
|
|
43
|
+
__name(bindArg, "bindArg");
|
|
44
|
+
|
|
45
|
+
// src/lib/hasExtname.ts
|
|
46
|
+
function hasExtname(tsFilepath, extnames) {
|
|
47
|
+
return new RegExp(`[.](${[
|
|
48
|
+
extnames
|
|
49
|
+
].flat(2).join("|")})$`).test(tsFilepath);
|
|
50
|
+
}
|
|
51
|
+
__name(hasExtname, "hasExtname");
|
|
52
|
+
hasExtname.js = bindArg(hasExtname, 1, [
|
|
53
|
+
"js",
|
|
54
|
+
"mjs",
|
|
55
|
+
"jsx",
|
|
56
|
+
"cjs"
|
|
57
|
+
]);
|
|
58
|
+
hasExtname.json = bindArg(hasExtname, 1, [
|
|
59
|
+
"json",
|
|
60
|
+
"jsonc"
|
|
61
|
+
]);
|
|
62
|
+
hasExtname.yaml = bindArg(hasExtname, 1, [
|
|
63
|
+
"yaml",
|
|
64
|
+
"yml"
|
|
65
|
+
]);
|
|
66
|
+
hasExtname.markdown = bindArg(hasExtname, 1, [
|
|
67
|
+
"md",
|
|
68
|
+
"markdown"
|
|
69
|
+
]);
|
|
70
|
+
hasExtname.ts = bindArg(hasExtname, 1, [
|
|
71
|
+
"ts",
|
|
72
|
+
"mts",
|
|
73
|
+
"tsx"
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
// src/lib/hasParentDirname.ts
|
|
77
|
+
function hasParentDirname(fspath, name) {
|
|
78
|
+
return new RegExp(`(^|[/\\\\])${name}[/\\\\]`).test(fspath);
|
|
79
|
+
}
|
|
80
|
+
__name(hasParentDirname, "hasParentDirname");
|
|
81
|
+
|
|
82
|
+
// src/lib/isDotFile.ts
|
|
83
|
+
function isDotFile(filepath) {
|
|
84
|
+
return /(?:^|[\\/])(\.(?!\.)[^\\/]+)$/.test(filepath);
|
|
85
|
+
}
|
|
86
|
+
__name(isDotFile, "isDotFile");
|
|
87
|
+
|
|
88
|
+
// src/lib/isExtValid.ts
|
|
89
|
+
function isExtValid(ext) {
|
|
90
|
+
return !!ext && ext !== "." && !/[<>"|?*:]/.test(ext);
|
|
91
|
+
}
|
|
92
|
+
__name(isExtValid, "isExtValid");
|
|
93
|
+
function isRelative(p) {
|
|
94
|
+
return !path.isAbsolute(p);
|
|
95
|
+
}
|
|
96
|
+
__name(isRelative, "isRelative");
|
|
97
|
+
|
|
98
|
+
// src/lib/isUnc.ts
|
|
99
|
+
function isUnc(filepath) {
|
|
100
|
+
return /^[\\/]{2,}[^\\/]+[\\/]+[^\\/]+/.test(filepath);
|
|
101
|
+
}
|
|
102
|
+
__name(isUnc, "isUnc");
|
|
103
|
+
|
|
104
|
+
// src/lib/isValidWin32.ts
|
|
105
|
+
function isValidWin32(path2, options) {
|
|
106
|
+
if (path2.length === 0) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
if (path2.indexOf("/") !== -1 && path2.indexOf("\\") !== -1) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
const maxLength = (options && options.extendedMaxLength ? 32767 : 260) - 12;
|
|
113
|
+
if (path2.length > maxLength) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
const noDriveLetter = /^\w:(\\|\/)/g.test(path2) ? path2.substring(2) : path2;
|
|
117
|
+
if (/[<>"|?*:]/g.test(noDriveLetter)) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
if (/(\\|\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\|\/)|$)/g.test(path2)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
__name(isValidWin32, "isValidWin32");
|
|
126
|
+
function prefixFilename(filePath, prefix) {
|
|
127
|
+
const ext = upath4.extname(filePath);
|
|
128
|
+
const fileNameWithoutExt = upath4.basename(filePath, ext);
|
|
129
|
+
return upath4.joinSafe(upath4.dirname(filePath), prefix + fileNameWithoutExt + ext);
|
|
130
|
+
}
|
|
131
|
+
__name(prefixFilename, "prefixFilename");
|
|
132
|
+
function root(p) {
|
|
133
|
+
return upath4.parse(p).root;
|
|
134
|
+
}
|
|
135
|
+
__name(root, "root");
|
|
136
|
+
function suffixFilename(filePath, suffix) {
|
|
137
|
+
const split = upath4.basename(filePath).split(".");
|
|
138
|
+
split[0] += suffix;
|
|
139
|
+
return upath4.joinSafe(upath4.dirname(filePath), split.join("."));
|
|
140
|
+
}
|
|
141
|
+
__name(suffixFilename, "suffixFilename");
|
|
142
|
+
function toCwdRelative(p) {
|
|
143
|
+
return upath4.relative(process.cwd(), p);
|
|
144
|
+
}
|
|
145
|
+
__name(toCwdRelative, "toCwdRelative");
|
|
146
|
+
|
|
147
|
+
// src/lib/toWin32.ts
|
|
148
|
+
function toWin32(p) {
|
|
149
|
+
return p.replace(/\//g, "\\");
|
|
150
|
+
}
|
|
151
|
+
__name(toWin32, "toWin32");
|
|
152
|
+
|
|
153
|
+
export { cwd, dirnameDeep, hasBasename, hasExtname, hasParentDirname, isDotFile, isExtValid, isRelative, isUnc, isValidWin32, prefixFilename, root, suffixFilename, toCwdRelative, toWin32 };
|
package/package.json
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/path",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "path",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"keywords": [
|
|
8
|
+
"path"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"import": "./index.mjs",
|
|
14
|
+
"default": "./index.mjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
7
17
|
"dependencies": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
18
|
+
"type-fest": "^5.4.4",
|
|
19
|
+
"upath": "^2.0.1"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
11
23
|
},
|
|
12
24
|
"license": "MIT",
|
|
13
|
-
"keywords": [],
|
|
14
25
|
"author": {
|
|
15
26
|
"name": "Benjamin Møller Jensen",
|
|
16
27
|
"email": "bemoje@bemoje.net",
|
|
@@ -18,14 +29,7 @@
|
|
|
18
29
|
},
|
|
19
30
|
"repository": {
|
|
20
31
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/bemoje/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"type": "patreon",
|
|
25
|
-
"url": "https://www.patreon.com/user?u=40752770"
|
|
26
|
-
},
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": "https://github.com/bemoje/tsmono/issues"
|
|
29
|
-
},
|
|
30
|
-
"homepage": "https://github.com/bemoje/tsmono"
|
|
32
|
+
"url": "git+https://github.com/bemoje/mono.git",
|
|
33
|
+
"directory": "libs/path"
|
|
34
|
+
}
|
|
31
35
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Benjamin Møller Jensen
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# @bemoje/path
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-

|
|
9
|
-
|
|
10
|
-

|
|
11
|
-

|
|
12
|
-

|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Documentation
|
|
16
|
-
[Documentation Website](https://bemoje.github.io/tsmono/modules/path.html)
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
This library is published in the NPM registry and can be installed using any compatible package manager.
|
|
20
|
-
|
|
21
|
-
#### NPM
|
|
22
|
-
```sh
|
|
23
|
-
npm install @bemoje/path
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## Issues
|
|
28
|
-
Please let me know of any bugs or [issues](https://github.com/bemoje/tsmono/issues).
|
|
29
|
-
|
|
30
|
-
## Contribute
|
|
31
|
-
Contributors are welcome to open a [pull request](https://github.com/bemoje/tsmono/pulls).
|
|
32
|
-
|
|
33
|
-
## License
|
|
34
|
-
Released under the [undefined License](./LICENSE).
|
package/cjs/index.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export * from './lib/createFileExtensionFilter';
|
|
2
|
-
export * from './lib/cwdpath';
|
|
3
|
-
export * from './lib/getAppDataPath';
|
|
4
|
-
export * from './lib/getDiskDrivesWindows';
|
|
5
|
-
export * from './lib/getDownloadsDirectory';
|
|
6
|
-
export * from './lib/getHomeDirectory';
|
|
7
|
-
export * from './lib/getTempDataPath';
|
|
8
|
-
export * from './lib/isValidFileExtension';
|
|
9
|
-
export * from './lib/isValidWindowsPath';
|
|
10
|
-
export * from './lib/normalizeFileExtension';
|
|
11
|
-
export * from './lib/pathAbsoluteToRelativeCwd';
|
|
12
|
-
export * from './lib/pathBasename';
|
|
13
|
-
export * from './lib/pathDirname';
|
|
14
|
-
export * from './lib/pathExtname';
|
|
15
|
-
export * from './lib/pathGetSeparator';
|
|
16
|
-
export * from './lib/pathIsAbsolute';
|
|
17
|
-
export * from './lib/pathIsDotFile';
|
|
18
|
-
export * from './lib/pathIsRelative';
|
|
19
|
-
export * from './lib/pathIsRelativePosix';
|
|
20
|
-
export * from './lib/pathIsRelativeWindows';
|
|
21
|
-
export * from './lib/pathIsUnc';
|
|
22
|
-
export * from './lib/pathJoin';
|
|
23
|
-
export * from './lib/pathRoot';
|
|
24
|
-
export * from './lib/toPosixPath';
|
|
25
|
-
//# sourceMappingURL=index.d.ts.map
|
package/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/path/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA;AAC/C,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA"}
|
package/cjs/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./lib/createFileExtensionFilter"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./lib/cwdpath"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./lib/getAppDataPath"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./lib/getDiskDrivesWindows"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./lib/getDownloadsDirectory"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./lib/getHomeDirectory"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./lib/getTempDataPath"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./lib/isValidFileExtension"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./lib/isValidWindowsPath"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./lib/normalizeFileExtension"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./lib/pathAbsoluteToRelativeCwd"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./lib/pathBasename"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./lib/pathDirname"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./lib/pathExtname"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./lib/pathGetSeparator"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./lib/pathIsAbsolute"), exports);
|
|
20
|
-
tslib_1.__exportStar(require("./lib/pathIsDotFile"), exports);
|
|
21
|
-
tslib_1.__exportStar(require("./lib/pathIsRelative"), exports);
|
|
22
|
-
tslib_1.__exportStar(require("./lib/pathIsRelativePosix"), exports);
|
|
23
|
-
tslib_1.__exportStar(require("./lib/pathIsRelativeWindows"), exports);
|
|
24
|
-
tslib_1.__exportStar(require("./lib/pathIsUnc"), exports);
|
|
25
|
-
tslib_1.__exportStar(require("./lib/pathJoin"), exports);
|
|
26
|
-
tslib_1.__exportStar(require("./lib/pathRoot"), exports);
|
|
27
|
-
tslib_1.__exportStar(require("./lib/toPosixPath"), exports);
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/path/src/index.ts"],"names":[],"mappings":";;;AAAA,0EAA+C;AAC/C,wDAA6B;AAC7B,+DAAoC;AACpC,qEAA0C;AAC1C,sEAA2C;AAC3C,iEAAsC;AACtC,gEAAqC;AACrC,qEAA0C;AAC1C,mEAAwC;AACxC,uEAA4C;AAC5C,0EAA+C;AAC/C,6DAAkC;AAClC,4DAAiC;AACjC,4DAAiC;AACjC,iEAAsC;AACtC,+DAAoC;AACpC,8DAAmC;AACnC,+DAAoC;AACpC,oEAAyC;AACzC,sEAA2C;AAC3C,0DAA+B;AAC/B,yDAA8B;AAC9B,yDAA8B;AAC9B,4DAAiC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Takes a list of file extensions and returns a filter function that returns true if a filepath/filename passed to it contains one of the given file extensions.
|
|
3
|
-
* @remarks If no file extensions are provided, the filter will always return true.
|
|
4
|
-
* @returns A function that takes a filepath and returns true if the filepath has one of the specified file extensions, false otherwise.
|
|
5
|
-
* @param fileExtensions file extensions
|
|
6
|
-
* @example ```ts
|
|
7
|
-
* createFileExtensionFilter(['.ts', '.tsx'])('index.ts');
|
|
8
|
-
* //=> true
|
|
9
|
-
* createFileExtensionFilter(['.ts', '.tsx'])('index.js');
|
|
10
|
-
* //=> false
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export declare function createFileExtensionFilter(fileExtensions: string[]): (filepath: string) => boolean;
|
|
14
|
-
//# sourceMappingURL=createFileExtensionFilter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFileExtensionFilter.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/createFileExtensionFilter.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAMjG"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFileExtensionFilter = void 0;
|
|
4
|
-
const normalizeFileExtension_1 = require("./normalizeFileExtension");
|
|
5
|
-
const pathExtname_1 = require("./pathExtname");
|
|
6
|
-
/**
|
|
7
|
-
* Takes a list of file extensions and returns a filter function that returns true if a filepath/filename passed to it contains one of the given file extensions.
|
|
8
|
-
* @remarks If no file extensions are provided, the filter will always return true.
|
|
9
|
-
* @returns A function that takes a filepath and returns true if the filepath has one of the specified file extensions, false otherwise.
|
|
10
|
-
* @param fileExtensions file extensions
|
|
11
|
-
* @example ```ts
|
|
12
|
-
* createFileExtensionFilter(['.ts', '.tsx'])('index.ts');
|
|
13
|
-
* //=> true
|
|
14
|
-
* createFileExtensionFilter(['.ts', '.tsx'])('index.js');
|
|
15
|
-
* //=> false
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
function createFileExtensionFilter(fileExtensions) {
|
|
19
|
-
if (!fileExtensions.length)
|
|
20
|
-
return (() => true);
|
|
21
|
-
const set = new Set(fileExtensions.map(normalizeFileExtension_1.normalizeFileExtension));
|
|
22
|
-
return (filepath) => {
|
|
23
|
-
return set.has((0, normalizeFileExtension_1.normalizeFileExtension)((0, pathExtname_1.pathExtname)(filepath)));
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.createFileExtensionFilter = createFileExtensionFilter;
|
|
27
|
-
//# sourceMappingURL=createFileExtensionFilter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFileExtensionFilter.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/createFileExtensionFilter.ts"],"names":[],"mappings":";;;AAAA,qEAAiE;AACjE,+CAA2C;AAE3C;;;;;;;;;;;GAWG;AACH,SAAgB,yBAAyB,CAAC,cAAwB;IAChE,IAAI,CAAC,cAAc,CAAC,MAAM;QAAE,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAkC,CAAA;IAChF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAS,cAAc,CAAC,GAAG,CAAC,+CAAsB,CAAC,CAAC,CAAA;IACvE,OAAO,CAAC,QAAgB,EAAE,EAAE;QAC1B,OAAO,GAAG,CAAC,GAAG,CAAC,IAAA,+CAAsB,EAAC,IAAA,yBAAW,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC/D,CAAC,CAAA;AACH,CAAC;AAND,8DAMC"}
|
package/cjs/lib/cwdpath.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Joins the given path segments to the current working directory path, and normalizes the resulting path.
|
|
3
|
-
* @remarks
|
|
4
|
-
* The function uses the `path.join` method from the Node.js `path` module, and the `process.cwd` method from the Node.js `process` module.
|
|
5
|
-
* @param paths - The path segments to join to the current working directory path.
|
|
6
|
-
* @returns The resulting path.
|
|
7
|
-
* @example ```ts
|
|
8
|
-
* console.log(cwdpath('src', 'index.ts'));
|
|
9
|
-
* //=> '{working_directory}/src/index.ts'
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export declare function cwdpath(...paths: string[]): string;
|
|
13
|
-
//# sourceMappingURL=cwdpath.d.ts.map
|
package/cjs/lib/cwdpath.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cwdpath.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/cwdpath.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAElD"}
|
package/cjs/lib/cwdpath.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cwdpath = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
-
/**
|
|
7
|
-
* Joins the given path segments to the current working directory path, and normalizes the resulting path.
|
|
8
|
-
* @remarks
|
|
9
|
-
* The function uses the `path.join` method from the Node.js `path` module, and the `process.cwd` method from the Node.js `process` module.
|
|
10
|
-
* @param paths - The path segments to join to the current working directory path.
|
|
11
|
-
* @returns The resulting path.
|
|
12
|
-
* @example ```ts
|
|
13
|
-
* console.log(cwdpath('src', 'index.ts'));
|
|
14
|
-
* //=> '{working_directory}/src/index.ts'
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
function cwdpath(...paths) {
|
|
18
|
-
return path_1.default.join(process.cwd(), ...paths);
|
|
19
|
-
}
|
|
20
|
-
exports.cwdpath = cwdpath;
|
|
21
|
-
//# sourceMappingURL=cwdpath.js.map
|
package/cjs/lib/cwdpath.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cwdpath.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/cwdpath.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AAEvB;;;;;;;;;;GAUG;AACH,SAAgB,OAAO,CAAC,GAAG,KAAe;IACxC,OAAO,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,0BAEC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAppDataPath.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getAppDataPath.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,UAkBjF"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAppDataPath = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const os_1 = tslib_1.__importDefault(require("os"));
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
const os_2 = require("@bemoje/os");
|
|
8
|
-
/**
|
|
9
|
-
* Get the app data path, depending on the current OS (win, osx, linux).
|
|
10
|
-
*/
|
|
11
|
-
function getAppDataPath(author, app, ...subdirs) {
|
|
12
|
-
let appDataPath = process.env['APPDATA'];
|
|
13
|
-
if (!appDataPath) {
|
|
14
|
-
const OS = (0, os_2.getOS)();
|
|
15
|
-
if (OS === 'windows') {
|
|
16
|
-
appDataPath = path_1.default.join(os_1.default.homedir(), 'AppData', 'Roaming');
|
|
17
|
-
}
|
|
18
|
-
else if (OS === 'osx') {
|
|
19
|
-
appDataPath = path_1.default.join(os_1.default.homedir(), 'Library', 'Application Support');
|
|
20
|
-
}
|
|
21
|
-
else if (OS === 'linux') {
|
|
22
|
-
appDataPath = path_1.default.join(os_1.default.homedir(), '.config');
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
throw new Error('Could not find an appropriate app data path');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (!author)
|
|
29
|
-
return appDataPath;
|
|
30
|
-
if (appDataPath === os_1.default.homedir())
|
|
31
|
-
author = '.' + author;
|
|
32
|
-
if (app)
|
|
33
|
-
subdirs.unshift(app);
|
|
34
|
-
return path_1.default.join(appDataPath, author, ...subdirs);
|
|
35
|
-
}
|
|
36
|
-
exports.getAppDataPath = getAppDataPath;
|
|
37
|
-
//# sourceMappingURL=getAppDataPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAppDataPath.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getAppDataPath.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AACnB,wDAAuB;AACvB,mCAAkC;AAElC;;GAEG;AACH,SAAgB,cAAc,CAAC,MAAe,EAAE,GAAY,EAAE,GAAG,OAAiB;IAChF,IAAI,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACxC,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,EAAE,GAAG,IAAA,UAAK,GAAE,CAAA;QAClB,IAAI,EAAE,KAAK,SAAS,EAAE;YACpB,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;SAC5D;aAAM,IAAI,EAAE,KAAK,KAAK,EAAE;YACvB,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,qBAAqB,CAAC,CAAA;SACxE;aAAM,IAAI,EAAE,KAAK,OAAO,EAAE;YACzB,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;SACjD;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;SAC/D;KACF;IACD,IAAI,CAAC,MAAM;QAAE,OAAO,WAAW,CAAA;IAC/B,IAAI,WAAW,KAAK,YAAE,CAAC,OAAO,EAAE;QAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAAA;IACvD,IAAI,GAAG;QAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC7B,OAAO,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAA;AACnD,CAAC;AAlBD,wCAkBC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This function retrieves information about the disk drives on a Windows system.
|
|
3
|
-
* It uses the Windows Management Instrumentation (WMI) to query the system for this information.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* getDiskDrivesWindows()
|
|
7
|
-
* //=> [ 'C:\\', 'G:\\' ]
|
|
8
|
-
*/
|
|
9
|
-
export declare function getDiskDrivesWindows(): string[];
|
|
10
|
-
//# sourceMappingURL=getDiskDrivesWindows.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDiskDrivesWindows.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getDiskDrivesWindows.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAO/C"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDiskDrivesWindows = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
/**
|
|
8
|
-
* This function retrieves information about the disk drives on a Windows system.
|
|
9
|
-
* It uses the Windows Management Instrumentation (WMI) to query the system for this information.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* getDiskDrivesWindows()
|
|
13
|
-
* //=> [ 'C:\\', 'G:\\' ]
|
|
14
|
-
*/
|
|
15
|
-
function getDiskDrivesWindows() {
|
|
16
|
-
return (0, child_process_1.execSync)('wmic logicaldisk get name')
|
|
17
|
-
.toString()
|
|
18
|
-
.split('\n')
|
|
19
|
-
.map((s) => s.trim())
|
|
20
|
-
.filter((s) => /^[a-z]:/i.test(s))
|
|
21
|
-
.map((s) => s.substring(0, 2) + path_1.default.sep);
|
|
22
|
-
}
|
|
23
|
-
exports.getDiskDrivesWindows = getDiskDrivesWindows;
|
|
24
|
-
//# sourceMappingURL=getDiskDrivesWindows.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDiskDrivesWindows.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getDiskDrivesWindows.ts"],"names":[],"mappings":";;;;AAAA,iDAAwC;AACxC,wDAAuB;AAEvB;;;;;;;GAOG;AACH,SAAgB,oBAAoB;IAClC,OAAO,IAAA,wBAAQ,EAAC,2BAA2B,CAAC;SACzC,QAAQ,EAAE;SACV,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,cAAI,CAAC,GAAG,CAAC,CAAA;AAC7C,CAAC;AAPD,oDAOC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type GetDownloadsFolder = () => string;
|
|
2
|
-
/**
|
|
3
|
-
* Returns the downloads directory of the current user.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getDownloadsDirectory(): string;
|
|
6
|
-
export declare namespace getDownloadsDirectory {
|
|
7
|
-
var osx: GetDownloadsFolder;
|
|
8
|
-
var linux: GetDownloadsFolder;
|
|
9
|
-
var windows: GetDownloadsFolder;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=getDownloadsDirectory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDownloadsDirectory.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getDownloadsDirectory.ts"],"names":[],"mappings":"AAOA,KAAK,kBAAkB,GAAG,MAAM,MAAM,CAAA;AA6BtC;;GAEG;AACH,wBAAgB,qBAAqB,WAIpC;yBAJe,qBAAqB"}
|