@bemoje/path 1.0.0 → 1.1.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/README.md +95 -0
- package/lib/index.cjs +110 -0
- package/lib/index.d.cts +16 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +15 -0
- package/lib/lib/cwd.cjs +16 -0
- package/lib/lib/cwd.d.cts +11 -0
- package/lib/lib/cwd.d.ts +11 -0
- package/lib/lib/cwd.js +9 -0
- package/lib/lib/dirnameDeep.cjs +17 -0
- package/lib/lib/dirnameDeep.d.cts +9 -0
- package/lib/lib/dirnameDeep.d.ts +9 -0
- package/lib/lib/dirnameDeep.js +10 -0
- package/lib/lib/hasBasename.cjs +18 -0
- package/lib/lib/hasBasename.d.cts +8 -0
- package/lib/lib/hasBasename.d.ts +8 -0
- package/lib/lib/hasBasename.js +11 -0
- package/lib/lib/hasExtname.cjs +37 -0
- package/lib/lib/hasExtname.d.cts +15 -0
- package/lib/lib/hasExtname.d.ts +15 -0
- package/lib/lib/hasExtname.js +34 -0
- package/lib/lib/hasParentDirname.cjs +10 -0
- package/lib/lib/hasParentDirname.d.cts +6 -0
- package/lib/lib/hasParentDirname.d.ts +6 -0
- package/lib/lib/hasParentDirname.js +8 -0
- package/lib/lib/isDotFile.cjs +10 -0
- package/lib/lib/isDotFile.d.cts +8 -0
- package/lib/lib/isDotFile.d.ts +8 -0
- package/lib/lib/isDotFile.js +8 -0
- package/lib/lib/isExtValid.cjs +10 -0
- package/lib/lib/isExtValid.d.cts +13 -0
- package/lib/lib/isExtValid.d.ts +13 -0
- package/lib/lib/isExtValid.js +8 -0
- package/lib/lib/isRelative.cjs +16 -0
- package/lib/lib/isRelative.d.cts +6 -0
- package/lib/lib/isRelative.d.ts +6 -0
- package/lib/lib/isRelative.js +9 -0
- package/lib/lib/isUnc.cjs +10 -0
- package/lib/lib/isUnc.d.cts +8 -0
- package/lib/lib/isUnc.d.ts +8 -0
- package/lib/lib/isUnc.js +8 -0
- package/lib/lib/isValidWin32.cjs +27 -0
- package/lib/lib/isValidWin32.d.cts +11 -0
- package/lib/lib/isValidWin32.d.ts +11 -0
- package/lib/lib/isValidWin32.js +25 -0
- package/lib/lib/prefixFilename.cjs +18 -0
- package/lib/lib/prefixFilename.d.cts +11 -0
- package/lib/lib/prefixFilename.d.ts +11 -0
- package/lib/lib/prefixFilename.js +11 -0
- package/lib/lib/root.cjs +16 -0
- package/lib/lib/root.d.cts +6 -0
- package/lib/lib/root.d.ts +6 -0
- package/lib/lib/root.js +9 -0
- package/lib/lib/suffixFilename.cjs +18 -0
- package/lib/lib/suffixFilename.d.cts +11 -0
- package/lib/lib/suffixFilename.d.ts +11 -0
- package/lib/lib/suffixFilename.js +11 -0
- package/lib/lib/toCwdRelative.cjs +16 -0
- package/lib/lib/toCwdRelative.d.cts +8 -0
- package/lib/lib/toCwdRelative.d.ts +8 -0
- package/lib/lib/toCwdRelative.js +9 -0
- package/lib/lib/toWin32.cjs +10 -0
- package/lib/lib/toWin32.d.cts +6 -0
- package/lib/lib/toWin32.d.ts +6 -0
- package/lib/lib/toWin32.js +8 -0
- package/package.json +249 -19
- package/index.d.ts +0 -121
- package/index.mjs +0 -153
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# @bemoje/path
|
|
2
|
+
|
|
3
|
+
Cross-platform path utilities extending upath with validation, manipulation, and inspection helpers.
|
|
4
|
+
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://nodejs.org/api/esm.html)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @bemoje/path
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### Working Directory Helpers
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { cwd, toCwdRelative } from '@bemoje/path'
|
|
20
|
+
|
|
21
|
+
// Join paths from cwd
|
|
22
|
+
cwd('src', 'index.ts') // /home/user/project/src/index.ts
|
|
23
|
+
|
|
24
|
+
// Convert absolute to cwd-relative
|
|
25
|
+
toCwdRelative('/home/user/project/src/index.ts') // 'src/index.ts'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Filename Manipulation
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { prefixFilename, suffixFilename } from '@bemoje/path'
|
|
32
|
+
|
|
33
|
+
prefixFilename('path/to/file.ts', 'new-') // 'path/to/new-file.ts'
|
|
34
|
+
suffixFilename('path/to/file.ts', '.bak') // 'path/to/file.bak.ts'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Path Inspection
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { hasExtname, hasBasename, hasParentDirname, isDotFile, isRelative, isUnc } from '@bemoje/path'
|
|
41
|
+
|
|
42
|
+
hasExtname('index.ts', ['ts', 'tsx']) // true
|
|
43
|
+
hasExtname.ts('index.ts') // true
|
|
44
|
+
hasExtname.json('config.json') // true
|
|
45
|
+
|
|
46
|
+
hasBasename('src/index.ts', 'index.ts') // true
|
|
47
|
+
hasParentDirname('src/lib/utils.ts', 'lib') // true
|
|
48
|
+
|
|
49
|
+
isDotFile('.gitignore') // true
|
|
50
|
+
isRelative('./src') // true
|
|
51
|
+
isUnc('\\\\server\\share') // true
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Validation
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { isValidWin32, isExtValid } from '@bemoje/path'
|
|
58
|
+
|
|
59
|
+
isValidWin32('C:\\Users\\file.txt') // true
|
|
60
|
+
isValidWin32('C:\\Users\\file<>.txt') // false
|
|
61
|
+
|
|
62
|
+
isExtValid('.ts') // true
|
|
63
|
+
isExtValid('') // false
|
|
64
|
+
isExtValid('.') // false
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Directory and Root Helpers
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { dirnameDeep, root, toWin32 } from '@bemoje/path'
|
|
71
|
+
|
|
72
|
+
dirnameDeep('a/b/c/d', 2) // 'a/b'
|
|
73
|
+
root('/home/user') // '/'
|
|
74
|
+
toWin32('path/to/file') // 'path\\to\\file'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## API Reference
|
|
78
|
+
|
|
79
|
+
| Export | Description |
|
|
80
|
+
| ------------------ | ---------------------------------------------- |
|
|
81
|
+
| `cwd` | Join paths from process.cwd() |
|
|
82
|
+
| `toCwdRelative` | Convert absolute path to cwd-relative |
|
|
83
|
+
| `prefixFilename` | Prepend string to filename |
|
|
84
|
+
| `suffixFilename` | Append string to filename (before extension) |
|
|
85
|
+
| `dirnameDeep` | Get parent directory N levels up |
|
|
86
|
+
| `hasBasename` | Check if path has a specific basename |
|
|
87
|
+
| `hasExtname` | Check if path has specific extension(s) |
|
|
88
|
+
| `hasParentDirname` | Check if path is under a parent directory name |
|
|
89
|
+
| `isDotFile` | Check if path is a dotfile |
|
|
90
|
+
| `isExtValid` | Validate a file extension |
|
|
91
|
+
| `isRelative` | Check if path is relative |
|
|
92
|
+
| `isUnc` | Check if path is a UNC path |
|
|
93
|
+
| `isValidWin32` | Validate a Windows file path |
|
|
94
|
+
| `root` | Get root directory of a path |
|
|
95
|
+
| `toWin32` | Convert forward slashes to backslashes |
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cwd = require('./lib/cwd');
|
|
4
|
+
var dirnameDeep = require('./lib/dirnameDeep');
|
|
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');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Object.keys(cwd).forEach(function (k) {
|
|
22
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return cwd[k]; }
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
Object.keys(dirnameDeep).forEach(function (k) {
|
|
28
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return dirnameDeep[k]; }
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
Object.keys(hasBasename).forEach(function (k) {
|
|
34
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return hasBasename[k]; }
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
Object.keys(hasExtname).forEach(function (k) {
|
|
40
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () { return hasExtname[k]; }
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
Object.keys(hasParentDirname).forEach(function (k) {
|
|
46
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () { return hasParentDirname[k]; }
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
Object.keys(isDotFile).forEach(function (k) {
|
|
52
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return isDotFile[k]; }
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
Object.keys(isExtValid).forEach(function (k) {
|
|
58
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () { return isExtValid[k]; }
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
Object.keys(isRelative).forEach(function (k) {
|
|
64
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () { return isRelative[k]; }
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
Object.keys(isUnc).forEach(function (k) {
|
|
70
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () { return isUnc[k]; }
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
Object.keys(isValidWin32).forEach(function (k) {
|
|
76
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () { return isValidWin32[k]; }
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
Object.keys(prefixFilename).forEach(function (k) {
|
|
82
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () { return prefixFilename[k]; }
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
Object.keys(root).forEach(function (k) {
|
|
88
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () { return root[k]; }
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
Object.keys(suffixFilename).forEach(function (k) {
|
|
94
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () { return suffixFilename[k]; }
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
Object.keys(toCwdRelative).forEach(function (k) {
|
|
100
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () { return toCwdRelative[k]; }
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
Object.keys(toWin32).forEach(function (k) {
|
|
106
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function () { return toWin32[k]; }
|
|
109
|
+
});
|
|
110
|
+
});
|
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { cwd } from './lib/cwd.cjs';
|
|
2
|
+
export { dirnameDeep } from './lib/dirnameDeep.cjs';
|
|
3
|
+
export { hasBasename } from './lib/hasBasename.cjs';
|
|
4
|
+
export { hasExtname } from './lib/hasExtname.cjs';
|
|
5
|
+
export { hasParentDirname } from './lib/hasParentDirname.cjs';
|
|
6
|
+
export { isDotFile } from './lib/isDotFile.cjs';
|
|
7
|
+
export { isExtValid } from './lib/isExtValid.cjs';
|
|
8
|
+
export { isRelative } from './lib/isRelative.cjs';
|
|
9
|
+
export { isUnc } from './lib/isUnc.cjs';
|
|
10
|
+
export { isValidWin32 } from './lib/isValidWin32.cjs';
|
|
11
|
+
export { prefixFilename } from './lib/prefixFilename.cjs';
|
|
12
|
+
export { root } from './lib/root.cjs';
|
|
13
|
+
export { suffixFilename } from './lib/suffixFilename.cjs';
|
|
14
|
+
export { toCwdRelative } from './lib/toCwdRelative.cjs';
|
|
15
|
+
export { toWin32 } from './lib/toWin32.cjs';
|
|
16
|
+
import './arrayable.d-1twOP8Y1.cjs';
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { cwd } from './lib/cwd.js';
|
|
2
|
+
export { dirnameDeep } from './lib/dirnameDeep.js';
|
|
3
|
+
export { hasBasename } from './lib/hasBasename.js';
|
|
4
|
+
export { hasExtname } from './lib/hasExtname.js';
|
|
5
|
+
export { hasParentDirname } from './lib/hasParentDirname.js';
|
|
6
|
+
export { isDotFile } from './lib/isDotFile.js';
|
|
7
|
+
export { isExtValid } from './lib/isExtValid.js';
|
|
8
|
+
export { isRelative } from './lib/isRelative.js';
|
|
9
|
+
export { isUnc } from './lib/isUnc.js';
|
|
10
|
+
export { isValidWin32 } from './lib/isValidWin32.js';
|
|
11
|
+
export { prefixFilename } from './lib/prefixFilename.js';
|
|
12
|
+
export { root } from './lib/root.js';
|
|
13
|
+
export { suffixFilename } from './lib/suffixFilename.js';
|
|
14
|
+
export { toCwdRelative } from './lib/toCwdRelative.js';
|
|
15
|
+
export { toWin32 } from './lib/toWin32.js';
|
|
16
|
+
import './arrayable.d-1twOP8Y1.js';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './lib/cwd';
|
|
2
|
+
export * from './lib/dirnameDeep';
|
|
3
|
+
export * from './lib/hasBasename';
|
|
4
|
+
export * from './lib/hasExtname';
|
|
5
|
+
export * from './lib/hasParentDirname';
|
|
6
|
+
export * from './lib/isDotFile';
|
|
7
|
+
export * from './lib/isExtValid';
|
|
8
|
+
export * from './lib/isRelative';
|
|
9
|
+
export * from './lib/isUnc';
|
|
10
|
+
export * from './lib/isValidWin32';
|
|
11
|
+
export * from './lib/prefixFilename';
|
|
12
|
+
export * from './lib/root';
|
|
13
|
+
export * from './lib/suffixFilename';
|
|
14
|
+
export * from './lib/toCwdRelative';
|
|
15
|
+
export * from './lib/toWin32';
|
package/lib/lib/cwd.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var upath = require('upath');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var upath__default = /*#__PURE__*/_interopDefault(upath);
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
+
function cwd(...p) {
|
|
12
|
+
return upath__default.default.joinSafe(process.cwd(), ...p);
|
|
13
|
+
}
|
|
14
|
+
__name(cwd, "cwd");
|
|
15
|
+
|
|
16
|
+
exports.cwd = cwd;
|
package/lib/lib/cwd.d.ts
ADDED
package/lib/lib/cwd.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var upath = require('upath');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var upath__default = /*#__PURE__*/_interopDefault(upath);
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
+
function dirnameDeep(p, depth) {
|
|
12
|
+
const parent = upath__default.default.dirname(p);
|
|
13
|
+
return depth && depth > 1 ? dirnameDeep(parent, depth - 1) : parent;
|
|
14
|
+
}
|
|
15
|
+
__name(dirnameDeep, "dirnameDeep");
|
|
16
|
+
|
|
17
|
+
exports.dirnameDeep = dirnameDeep;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the absolute path of the parent directory of the given path.
|
|
3
|
+
* @param p the path
|
|
4
|
+
* @param depth how many times to get the parent directory
|
|
5
|
+
* @example dirnameDeep('a/b/c/d', 2) => 'a/b'
|
|
6
|
+
*/
|
|
7
|
+
declare function dirnameDeep(p: string, depth?: number): string;
|
|
8
|
+
|
|
9
|
+
export { dirnameDeep };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the absolute path of the parent directory of the given path.
|
|
3
|
+
* @param p the path
|
|
4
|
+
* @param depth how many times to get the parent directory
|
|
5
|
+
* @example dirnameDeep('a/b/c/d', 2) => 'a/b'
|
|
6
|
+
*/
|
|
7
|
+
declare function dirnameDeep(p: string, depth?: number): string;
|
|
8
|
+
|
|
9
|
+
export { dirnameDeep };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
|
+
import upath from 'upath';
|
|
3
|
+
|
|
4
|
+
function dirnameDeep(p, depth) {
|
|
5
|
+
const parent = upath.dirname(p);
|
|
6
|
+
return depth && depth > 1 ? dirnameDeep(parent, depth - 1) : parent;
|
|
7
|
+
}
|
|
8
|
+
__name(dirnameDeep, "dirnameDeep");
|
|
9
|
+
|
|
10
|
+
export { dirnameDeep };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var upath = require('upath');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var upath__default = /*#__PURE__*/_interopDefault(upath);
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
+
function hasBasename(tsFilepath, basenames) {
|
|
12
|
+
return [
|
|
13
|
+
basenames
|
|
14
|
+
].flat(2).includes(upath__default.default.basename(tsFilepath));
|
|
15
|
+
}
|
|
16
|
+
__name(hasBasename, "hasBasename");
|
|
17
|
+
|
|
18
|
+
exports.hasBasename = hasBasename;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
|
+
import upath from 'upath';
|
|
3
|
+
|
|
4
|
+
function hasBasename(tsFilepath, basenames) {
|
|
5
|
+
return [
|
|
6
|
+
basenames
|
|
7
|
+
].flat(2).includes(upath.basename(tsFilepath));
|
|
8
|
+
}
|
|
9
|
+
__name(hasBasename, "hasBasename");
|
|
10
|
+
|
|
11
|
+
export { hasBasename };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fn = require('@mono/fn');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
function hasExtname(tsFilepath, extnames) {
|
|
8
|
+
return new RegExp(`[.](${[
|
|
9
|
+
extnames
|
|
10
|
+
].flat(2).join("|")})$`).test(tsFilepath);
|
|
11
|
+
}
|
|
12
|
+
__name(hasExtname, "hasExtname");
|
|
13
|
+
hasExtname.js = fn.bindArg(hasExtname, 1, [
|
|
14
|
+
"js",
|
|
15
|
+
"mjs",
|
|
16
|
+
"jsx",
|
|
17
|
+
"cjs"
|
|
18
|
+
]);
|
|
19
|
+
hasExtname.json = fn.bindArg(hasExtname, 1, [
|
|
20
|
+
"json",
|
|
21
|
+
"jsonc"
|
|
22
|
+
]);
|
|
23
|
+
hasExtname.yaml = fn.bindArg(hasExtname, 1, [
|
|
24
|
+
"yaml",
|
|
25
|
+
"yml"
|
|
26
|
+
]);
|
|
27
|
+
hasExtname.markdown = fn.bindArg(hasExtname, 1, [
|
|
28
|
+
"md",
|
|
29
|
+
"markdown"
|
|
30
|
+
]);
|
|
31
|
+
hasExtname.ts = fn.bindArg(hasExtname, 1, [
|
|
32
|
+
"ts",
|
|
33
|
+
"mts",
|
|
34
|
+
"tsx"
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
exports.hasExtname = hasExtname;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { A as Arrayable } from '../arrayable.d-1twOP8Y1.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a file path has any of the specified file extensions.
|
|
5
|
+
*/
|
|
6
|
+
declare function hasExtname(tsFilepath: string, extnames: Arrayable<string>): boolean;
|
|
7
|
+
declare namespace hasExtname {
|
|
8
|
+
var js: (tsFilepath: string) => boolean;
|
|
9
|
+
var json: (tsFilepath: string) => boolean;
|
|
10
|
+
var yaml: (tsFilepath: string) => boolean;
|
|
11
|
+
var markdown: (tsFilepath: string) => boolean;
|
|
12
|
+
var ts: (tsFilepath: string) => boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { hasExtname };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { A as Arrayable } from '../arrayable.d-1twOP8Y1.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a file path has any of the specified file extensions.
|
|
5
|
+
*/
|
|
6
|
+
declare function hasExtname(tsFilepath: string, extnames: Arrayable<string>): boolean;
|
|
7
|
+
declare namespace hasExtname {
|
|
8
|
+
var js: (tsFilepath: string) => boolean;
|
|
9
|
+
var json: (tsFilepath: string) => boolean;
|
|
10
|
+
var yaml: (tsFilepath: string) => boolean;
|
|
11
|
+
var markdown: (tsFilepath: string) => boolean;
|
|
12
|
+
var ts: (tsFilepath: string) => boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { hasExtname };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
|
+
import { bindArg } from '@mono/fn';
|
|
3
|
+
|
|
4
|
+
function hasExtname(tsFilepath, extnames) {
|
|
5
|
+
return new RegExp(`[.](${[
|
|
6
|
+
extnames
|
|
7
|
+
].flat(2).join("|")})$`).test(tsFilepath);
|
|
8
|
+
}
|
|
9
|
+
__name(hasExtname, "hasExtname");
|
|
10
|
+
hasExtname.js = bindArg(hasExtname, 1, [
|
|
11
|
+
"js",
|
|
12
|
+
"mjs",
|
|
13
|
+
"jsx",
|
|
14
|
+
"cjs"
|
|
15
|
+
]);
|
|
16
|
+
hasExtname.json = bindArg(hasExtname, 1, [
|
|
17
|
+
"json",
|
|
18
|
+
"jsonc"
|
|
19
|
+
]);
|
|
20
|
+
hasExtname.yaml = bindArg(hasExtname, 1, [
|
|
21
|
+
"yaml",
|
|
22
|
+
"yml"
|
|
23
|
+
]);
|
|
24
|
+
hasExtname.markdown = bindArg(hasExtname, 1, [
|
|
25
|
+
"md",
|
|
26
|
+
"markdown"
|
|
27
|
+
]);
|
|
28
|
+
hasExtname.ts = bindArg(hasExtname, 1, [
|
|
29
|
+
"ts",
|
|
30
|
+
"mts",
|
|
31
|
+
"tsx"
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
export { hasExtname };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function hasParentDirname(fspath, name) {
|
|
6
|
+
return new RegExp(`(^|[/\\\\])${name}[/\\\\]`).test(fspath);
|
|
7
|
+
}
|
|
8
|
+
__name(hasParentDirname, "hasParentDirname");
|
|
9
|
+
|
|
10
|
+
exports.hasParentDirname = hasParentDirname;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function isDotFile(filepath) {
|
|
6
|
+
return /(?:^|[/\\])(\.(?!\.)[^/\\]+)$/.test(filepath);
|
|
7
|
+
}
|
|
8
|
+
__name(isDotFile, "isDotFile");
|
|
9
|
+
|
|
10
|
+
exports.isDotFile = isDotFile;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function isExtValid(ext) {
|
|
6
|
+
return !!ext && ext !== "." && !/["*:<>?|]/.test(ext);
|
|
7
|
+
}
|
|
8
|
+
__name(isExtValid, "isExtValid");
|
|
9
|
+
|
|
10
|
+
exports.isExtValid = isExtValid;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a file extension is valid.
|
|
3
|
+
*
|
|
4
|
+
* Invalid:
|
|
5
|
+
* - empty string
|
|
6
|
+
* - single dot: "."
|
|
7
|
+
* - illegal characters: <>"|?*:
|
|
8
|
+
*
|
|
9
|
+
* @param ext - The file extension to check.
|
|
10
|
+
*/
|
|
11
|
+
declare function isExtValid(ext: string): boolean;
|
|
12
|
+
|
|
13
|
+
export { isExtValid };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a file extension is valid.
|
|
3
|
+
*
|
|
4
|
+
* Invalid:
|
|
5
|
+
* - empty string
|
|
6
|
+
* - single dot: "."
|
|
7
|
+
* - illegal characters: <>"|?*:
|
|
8
|
+
*
|
|
9
|
+
* @param ext - The file extension to check.
|
|
10
|
+
*/
|
|
11
|
+
declare function isExtValid(ext: string): boolean;
|
|
12
|
+
|
|
13
|
+
export { isExtValid };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
+
function isRelative(p) {
|
|
12
|
+
return !path__default.default.isAbsolute(p);
|
|
13
|
+
}
|
|
14
|
+
__name(isRelative, "isRelative");
|
|
15
|
+
|
|
16
|
+
exports.isRelative = isRelative;
|