@bemoje/path 1.1.0 → 1.1.1
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/lib/index.cjs +169 -105
- package/lib/index.js +153 -15
- package/lib/lib/cwd.js +2 -1
- package/lib/lib/dirnameDeep.js +2 -1
- package/lib/lib/hasBasename.js +2 -1
- package/lib/lib/hasExtname.cjs +30 -7
- package/lib/lib/hasExtname.js +26 -2
- package/lib/lib/hasParentDirname.cjs +2 -0
- package/lib/lib/hasParentDirname.js +3 -1
- package/lib/lib/isDotFile.cjs +2 -0
- package/lib/lib/isDotFile.js +3 -1
- package/lib/lib/isExtValid.cjs +2 -0
- package/lib/lib/isExtValid.js +3 -1
- package/lib/lib/isRelative.js +2 -1
- package/lib/lib/isUnc.cjs +2 -0
- package/lib/lib/isUnc.js +3 -1
- package/lib/lib/isValidWin32.cjs +2 -0
- package/lib/lib/isValidWin32.js +3 -1
- package/lib/lib/prefixFilename.js +2 -1
- package/lib/lib/root.js +2 -1
- package/lib/lib/suffixFilename.js +2 -1
- package/lib/lib/toCwdRelative.js +2 -1
- package/lib/lib/toWin32.cjs +2 -0
- package/lib/lib/toWin32.js +3 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1,110 +1,174 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var hasBasename = require('./lib/hasBasename');
|
|
6
|
-
var hasExtname = require('./lib/hasExtname');
|
|
7
|
-
var hasParentDirname = require('./lib/hasParentDirname');
|
|
8
|
-
var isDotFile = require('./lib/isDotFile');
|
|
9
|
-
var isExtValid = require('./lib/isExtValid');
|
|
10
|
-
var isRelative = require('./lib/isRelative');
|
|
11
|
-
var isUnc = require('./lib/isUnc');
|
|
12
|
-
var isValidWin32 = require('./lib/isValidWin32');
|
|
13
|
-
var prefixFilename = require('./lib/prefixFilename');
|
|
14
|
-
var root = require('./lib/root');
|
|
15
|
-
var suffixFilename = require('./lib/suffixFilename');
|
|
16
|
-
var toCwdRelative = require('./lib/toCwdRelative');
|
|
17
|
-
var toWin32 = require('./lib/toWin32');
|
|
3
|
+
var upath4 = require('upath');
|
|
4
|
+
var path = require('path');
|
|
18
5
|
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
7
|
|
|
8
|
+
var upath4__default = /*#__PURE__*/_interopDefault(upath4);
|
|
9
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
20
10
|
|
|
21
|
-
Object.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
function cwd(...p) {
|
|
14
|
+
return upath4__default.default.joinSafe(process.cwd(), ...p);
|
|
15
|
+
}
|
|
16
|
+
__name(cwd, "cwd");
|
|
17
|
+
function dirnameDeep(p, depth) {
|
|
18
|
+
const parent = upath4__default.default.dirname(p);
|
|
19
|
+
return depth && depth > 1 ? dirnameDeep(parent, depth - 1) : parent;
|
|
20
|
+
}
|
|
21
|
+
__name(dirnameDeep, "dirnameDeep");
|
|
22
|
+
function hasBasename(tsFilepath, basenames) {
|
|
23
|
+
return [
|
|
24
|
+
basenames
|
|
25
|
+
].flat(2).includes(upath4__default.default.basename(tsFilepath));
|
|
26
|
+
}
|
|
27
|
+
__name(hasBasename, "hasBasename");
|
|
28
|
+
|
|
29
|
+
// ../fn/src/setNameAndLength.ts
|
|
30
|
+
function setNameAndLength(source, target, lengthDelta = 0) {
|
|
31
|
+
return Object.defineProperties(target, {
|
|
32
|
+
name: {
|
|
33
|
+
configurable: true,
|
|
34
|
+
value: source.name
|
|
35
|
+
},
|
|
36
|
+
length: {
|
|
37
|
+
configurable: true,
|
|
38
|
+
value: source.length + lengthDelta
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
__name(setNameAndLength, "setNameAndLength");
|
|
43
|
+
|
|
44
|
+
// ../fn/src/bindArg.ts
|
|
45
|
+
function bindArg(fn, boundArgIndex, boundArgValue) {
|
|
46
|
+
return setNameAndLength(fn, (...args) => {
|
|
47
|
+
return fn(...args.slice(0, boundArgIndex), boundArgValue, ...args.slice(boundArgIndex));
|
|
48
|
+
}, -1);
|
|
49
|
+
}
|
|
50
|
+
__name(bindArg, "bindArg");
|
|
51
|
+
|
|
52
|
+
// src/lib/hasExtname.ts
|
|
53
|
+
function hasExtname(tsFilepath, extnames) {
|
|
54
|
+
return new RegExp(`[.](${[
|
|
55
|
+
extnames
|
|
56
|
+
].flat(2).join("|")})$`).test(tsFilepath);
|
|
57
|
+
}
|
|
58
|
+
__name(hasExtname, "hasExtname");
|
|
59
|
+
hasExtname.js = bindArg(hasExtname, 1, [
|
|
60
|
+
"js",
|
|
61
|
+
"mjs",
|
|
62
|
+
"jsx",
|
|
63
|
+
"cjs"
|
|
64
|
+
]);
|
|
65
|
+
hasExtname.json = bindArg(hasExtname, 1, [
|
|
66
|
+
"json",
|
|
67
|
+
"jsonc"
|
|
68
|
+
]);
|
|
69
|
+
hasExtname.yaml = bindArg(hasExtname, 1, [
|
|
70
|
+
"yaml",
|
|
71
|
+
"yml"
|
|
72
|
+
]);
|
|
73
|
+
hasExtname.markdown = bindArg(hasExtname, 1, [
|
|
74
|
+
"md",
|
|
75
|
+
"markdown"
|
|
76
|
+
]);
|
|
77
|
+
hasExtname.ts = bindArg(hasExtname, 1, [
|
|
78
|
+
"ts",
|
|
79
|
+
"mts",
|
|
80
|
+
"tsx"
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
// src/lib/hasParentDirname.ts
|
|
84
|
+
function hasParentDirname(fspath, name) {
|
|
85
|
+
return new RegExp(`(^|[/\\\\])${name}[/\\\\]`).test(fspath);
|
|
86
|
+
}
|
|
87
|
+
__name(hasParentDirname, "hasParentDirname");
|
|
88
|
+
|
|
89
|
+
// src/lib/isDotFile.ts
|
|
90
|
+
function isDotFile(filepath) {
|
|
91
|
+
return /(?:^|[/\\])(\.(?!\.)[^/\\]+)$/.test(filepath);
|
|
92
|
+
}
|
|
93
|
+
__name(isDotFile, "isDotFile");
|
|
94
|
+
|
|
95
|
+
// src/lib/isExtValid.ts
|
|
96
|
+
function isExtValid(ext) {
|
|
97
|
+
return !!ext && ext !== "." && !/["*:<>?|]/.test(ext);
|
|
98
|
+
}
|
|
99
|
+
__name(isExtValid, "isExtValid");
|
|
100
|
+
function isRelative(p) {
|
|
101
|
+
return !path__default.default.isAbsolute(p);
|
|
102
|
+
}
|
|
103
|
+
__name(isRelative, "isRelative");
|
|
104
|
+
|
|
105
|
+
// src/lib/isUnc.ts
|
|
106
|
+
function isUnc(filepath) {
|
|
107
|
+
return /^[/\\]{2,}[^/\\]+[/\\]+[^/\\]+/.test(filepath);
|
|
108
|
+
}
|
|
109
|
+
__name(isUnc, "isUnc");
|
|
110
|
+
|
|
111
|
+
// src/lib/isValidWin32.ts
|
|
112
|
+
function isValidWin32(path2, options) {
|
|
113
|
+
if (path2.length === 0) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (path2.includes("/") && path2.includes("\\")) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const maxLength = (options && options.extendedMaxLength ? 32767 : 260) - 12;
|
|
120
|
+
if (path2.length > maxLength) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
const noDriveLetter = /^\w:(\\|\/)/g.test(path2) ? path2.substring(2) : path2;
|
|
124
|
+
if (/["*:<>?|]/g.test(noDriveLetter)) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
if (/(\\|\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\|\/)|$)/g.test(path2)) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
__name(isValidWin32, "isValidWin32");
|
|
133
|
+
function prefixFilename(filePath, prefix) {
|
|
134
|
+
const ext = upath4__default.default.extname(filePath);
|
|
135
|
+
const fileNameWithoutExt = upath4__default.default.basename(filePath, ext);
|
|
136
|
+
return upath4__default.default.joinSafe(upath4__default.default.dirname(filePath), prefix + fileNameWithoutExt + ext);
|
|
137
|
+
}
|
|
138
|
+
__name(prefixFilename, "prefixFilename");
|
|
139
|
+
function root(p) {
|
|
140
|
+
return upath4__default.default.parse(p).root;
|
|
141
|
+
}
|
|
142
|
+
__name(root, "root");
|
|
143
|
+
function suffixFilename(filePath, suffix) {
|
|
144
|
+
const split = upath4__default.default.basename(filePath).split(".");
|
|
145
|
+
split[0] += suffix;
|
|
146
|
+
return upath4__default.default.joinSafe(upath4__default.default.dirname(filePath), split.join("."));
|
|
147
|
+
}
|
|
148
|
+
__name(suffixFilename, "suffixFilename");
|
|
149
|
+
function toCwdRelative(p) {
|
|
150
|
+
return upath4__default.default.relative(process.cwd(), p);
|
|
151
|
+
}
|
|
152
|
+
__name(toCwdRelative, "toCwdRelative");
|
|
153
|
+
|
|
154
|
+
// src/lib/toWin32.ts
|
|
155
|
+
function toWin32(p) {
|
|
156
|
+
return p.replaceAll("/", "\\");
|
|
157
|
+
}
|
|
158
|
+
__name(toWin32, "toWin32");
|
|
159
|
+
|
|
160
|
+
exports.cwd = cwd;
|
|
161
|
+
exports.dirnameDeep = dirnameDeep;
|
|
162
|
+
exports.hasBasename = hasBasename;
|
|
163
|
+
exports.hasExtname = hasExtname;
|
|
164
|
+
exports.hasParentDirname = hasParentDirname;
|
|
165
|
+
exports.isDotFile = isDotFile;
|
|
166
|
+
exports.isExtValid = isExtValid;
|
|
167
|
+
exports.isRelative = isRelative;
|
|
168
|
+
exports.isUnc = isUnc;
|
|
169
|
+
exports.isValidWin32 = isValidWin32;
|
|
170
|
+
exports.prefixFilename = prefixFilename;
|
|
171
|
+
exports.root = root;
|
|
172
|
+
exports.suffixFilename = suffixFilename;
|
|
173
|
+
exports.toCwdRelative = toCwdRelative;
|
|
174
|
+
exports.toWin32 = toWin32;
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,153 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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/setNameAndLength.ts
|
|
23
|
+
function setNameAndLength(source, target, lengthDelta = 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 + lengthDelta
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
__name(setNameAndLength, "setNameAndLength");
|
|
36
|
+
|
|
37
|
+
// ../fn/src/bindArg.ts
|
|
38
|
+
function bindArg(fn, boundArgIndex, boundArgValue) {
|
|
39
|
+
return setNameAndLength(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.includes("/") && path2.includes("\\")) {
|
|
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.replaceAll("/", "\\");
|
|
150
|
+
}
|
|
151
|
+
__name(toWin32, "toWin32");
|
|
152
|
+
|
|
153
|
+
export { cwd, dirnameDeep, hasBasename, hasExtname, hasParentDirname, isDotFile, isExtValid, isRelative, isUnc, isValidWin32, prefixFilename, root, suffixFilename, toCwdRelative, toWin32 };
|
package/lib/lib/cwd.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
1
|
import upath from 'upath';
|
|
3
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
5
|
function cwd(...p) {
|
|
5
6
|
return upath.joinSafe(process.cwd(), ...p);
|
|
6
7
|
}
|
package/lib/lib/dirnameDeep.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
1
|
import upath from 'upath';
|
|
3
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
5
|
function dirnameDeep(p, depth) {
|
|
5
6
|
const parent = upath.dirname(p);
|
|
6
7
|
return depth && depth > 1 ? dirnameDeep(parent, depth - 1) : parent;
|
package/lib/lib/hasBasename.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
1
|
import upath from 'upath';
|
|
3
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
5
|
function hasBasename(tsFilepath, basenames) {
|
|
5
6
|
return [
|
|
6
7
|
basenames
|
package/lib/lib/hasExtname.cjs
CHANGED
|
@@ -1,34 +1,57 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fn = require('@mono/fn');
|
|
4
|
-
|
|
5
3
|
var __defProp = Object.defineProperty;
|
|
6
4
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
|
|
6
|
+
// ../fn/src/setNameAndLength.ts
|
|
7
|
+
function setNameAndLength(source, target, lengthDelta = 0) {
|
|
8
|
+
return Object.defineProperties(target, {
|
|
9
|
+
name: {
|
|
10
|
+
configurable: true,
|
|
11
|
+
value: source.name
|
|
12
|
+
},
|
|
13
|
+
length: {
|
|
14
|
+
configurable: true,
|
|
15
|
+
value: source.length + lengthDelta
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
__name(setNameAndLength, "setNameAndLength");
|
|
20
|
+
|
|
21
|
+
// ../fn/src/bindArg.ts
|
|
22
|
+
function bindArg(fn, boundArgIndex, boundArgValue) {
|
|
23
|
+
return setNameAndLength(fn, (...args) => {
|
|
24
|
+
return fn(...args.slice(0, boundArgIndex), boundArgValue, ...args.slice(boundArgIndex));
|
|
25
|
+
}, -1);
|
|
26
|
+
}
|
|
27
|
+
__name(bindArg, "bindArg");
|
|
28
|
+
|
|
29
|
+
// src/lib/hasExtname.ts
|
|
7
30
|
function hasExtname(tsFilepath, extnames) {
|
|
8
31
|
return new RegExp(`[.](${[
|
|
9
32
|
extnames
|
|
10
33
|
].flat(2).join("|")})$`).test(tsFilepath);
|
|
11
34
|
}
|
|
12
35
|
__name(hasExtname, "hasExtname");
|
|
13
|
-
hasExtname.js =
|
|
36
|
+
hasExtname.js = bindArg(hasExtname, 1, [
|
|
14
37
|
"js",
|
|
15
38
|
"mjs",
|
|
16
39
|
"jsx",
|
|
17
40
|
"cjs"
|
|
18
41
|
]);
|
|
19
|
-
hasExtname.json =
|
|
42
|
+
hasExtname.json = bindArg(hasExtname, 1, [
|
|
20
43
|
"json",
|
|
21
44
|
"jsonc"
|
|
22
45
|
]);
|
|
23
|
-
hasExtname.yaml =
|
|
46
|
+
hasExtname.yaml = bindArg(hasExtname, 1, [
|
|
24
47
|
"yaml",
|
|
25
48
|
"yml"
|
|
26
49
|
]);
|
|
27
|
-
hasExtname.markdown =
|
|
50
|
+
hasExtname.markdown = bindArg(hasExtname, 1, [
|
|
28
51
|
"md",
|
|
29
52
|
"markdown"
|
|
30
53
|
]);
|
|
31
|
-
hasExtname.ts =
|
|
54
|
+
hasExtname.ts = bindArg(hasExtname, 1, [
|
|
32
55
|
"ts",
|
|
33
56
|
"mts",
|
|
34
57
|
"tsx"
|
package/lib/lib/hasExtname.js
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
+
// ../fn/src/setNameAndLength.ts
|
|
5
|
+
function setNameAndLength(source, target, lengthDelta = 0) {
|
|
6
|
+
return Object.defineProperties(target, {
|
|
7
|
+
name: {
|
|
8
|
+
configurable: true,
|
|
9
|
+
value: source.name
|
|
10
|
+
},
|
|
11
|
+
length: {
|
|
12
|
+
configurable: true,
|
|
13
|
+
value: source.length + lengthDelta
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
__name(setNameAndLength, "setNameAndLength");
|
|
18
|
+
|
|
19
|
+
// ../fn/src/bindArg.ts
|
|
20
|
+
function bindArg(fn, boundArgIndex, boundArgValue) {
|
|
21
|
+
return setNameAndLength(fn, (...args) => {
|
|
22
|
+
return fn(...args.slice(0, boundArgIndex), boundArgValue, ...args.slice(boundArgIndex));
|
|
23
|
+
}, -1);
|
|
24
|
+
}
|
|
25
|
+
__name(bindArg, "bindArg");
|
|
26
|
+
|
|
27
|
+
// src/lib/hasExtname.ts
|
|
4
28
|
function hasExtname(tsFilepath, extnames) {
|
|
5
29
|
return new RegExp(`[.](${[
|
|
6
30
|
extnames
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
|
|
6
|
+
// src/lib/hasParentDirname.ts
|
|
5
7
|
function hasParentDirname(fspath, name) {
|
|
6
8
|
return new RegExp(`(^|[/\\\\])${name}[/\\\\]`).test(fspath);
|
|
7
9
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
3
|
|
|
4
|
+
// src/lib/hasParentDirname.ts
|
|
3
5
|
function hasParentDirname(fspath, name) {
|
|
4
6
|
return new RegExp(`(^|[/\\\\])${name}[/\\\\]`).test(fspath);
|
|
5
7
|
}
|
package/lib/lib/isDotFile.cjs
CHANGED
package/lib/lib/isDotFile.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
3
|
|
|
4
|
+
// src/lib/isDotFile.ts
|
|
3
5
|
function isDotFile(filepath) {
|
|
4
6
|
return /(?:^|[/\\])(\.(?!\.)[^/\\]+)$/.test(filepath);
|
|
5
7
|
}
|
package/lib/lib/isExtValid.cjs
CHANGED
package/lib/lib/isExtValid.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
3
|
|
|
4
|
+
// src/lib/isExtValid.ts
|
|
3
5
|
function isExtValid(ext) {
|
|
4
6
|
return !!ext && ext !== "." && !/["*:<>?|]/.test(ext);
|
|
5
7
|
}
|
package/lib/lib/isRelative.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
1
|
import path from 'path';
|
|
3
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
5
|
function isRelative(p) {
|
|
5
6
|
return !path.isAbsolute(p);
|
|
6
7
|
}
|
package/lib/lib/isUnc.cjs
CHANGED
package/lib/lib/isUnc.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
3
|
|
|
4
|
+
// src/lib/isUnc.ts
|
|
3
5
|
function isUnc(filepath) {
|
|
4
6
|
return /^[/\\]{2,}[^/\\]+[/\\]+[^/\\]+/.test(filepath);
|
|
5
7
|
}
|
package/lib/lib/isValidWin32.cjs
CHANGED
package/lib/lib/isValidWin32.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
3
|
|
|
4
|
+
// src/lib/isValidWin32.ts
|
|
3
5
|
function isValidWin32(path, options) {
|
|
4
6
|
if (path.length === 0) {
|
|
5
7
|
return false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
1
|
import upath from 'upath';
|
|
3
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
5
|
function prefixFilename(filePath, prefix) {
|
|
5
6
|
const ext = upath.extname(filePath);
|
|
6
7
|
const fileNameWithoutExt = upath.basename(filePath, ext);
|
package/lib/lib/root.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
1
|
import upath from 'upath';
|
|
3
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
5
|
function suffixFilename(filePath, suffix) {
|
|
5
6
|
const split = upath.basename(filePath).split(".");
|
|
6
7
|
split[0] += suffix;
|
package/lib/lib/toCwdRelative.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
1
|
import upath from 'upath';
|
|
3
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
5
|
function toCwdRelative(p) {
|
|
5
6
|
return upath.relative(process.cwd(), p);
|
|
6
7
|
}
|
package/lib/lib/toWin32.cjs
CHANGED
package/lib/lib/toWin32.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
3
|
|
|
4
|
+
// src/lib/toWin32.ts
|
|
3
5
|
function toWin32(p) {
|
|
4
6
|
return p.replaceAll("/", "\\");
|
|
5
7
|
}
|