@archoleat/validate-font-file-name 1.2.7 → 1.2.8
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 +42 -5
- package/package.json +13 -6
package/README.md
CHANGED
|
@@ -12,29 +12,66 @@
|
|
|
12
12
|
## Table of Contents
|
|
13
13
|
|
|
14
14
|
- [Installation](#installation)
|
|
15
|
+
- [Runtime](#runtime)
|
|
15
16
|
- [Usage](#usage)
|
|
16
17
|
- [Contributing](#contributing)
|
|
17
18
|
- [License](#license)
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
Check font filenames against a naming convention in Node.js.
|
|
20
21
|
|
|
21
22
|
## Installation
|
|
22
23
|
|
|
23
24
|
```shell
|
|
24
|
-
bun i
|
|
25
|
+
bun i @archoleat/validate-font-file-name
|
|
25
26
|
```
|
|
26
27
|
|
|
28
|
+
Use `bun i -D @archoleat/validate-font-file-name` for build-only validation.
|
|
29
|
+
|
|
30
|
+
## Runtime
|
|
31
|
+
|
|
32
|
+
This ES module targets Node.js tooling: it uses `node:path` and a console
|
|
33
|
+
notifier. It does not inspect font binaries or require the file to exist.
|
|
34
|
+
Bun is used for repository tooling, not required by the published module.
|
|
35
|
+
|
|
27
36
|
## Usage
|
|
28
37
|
|
|
29
38
|
```js
|
|
30
39
|
import { validateFontFileName } from '@archoleat/validate-font-file-name';
|
|
31
40
|
|
|
32
|
-
await validateFontFileName({
|
|
33
|
-
file:
|
|
34
|
-
|
|
41
|
+
const isValid = await validateFontFileName({
|
|
42
|
+
file: 'public/fonts/Roboto-Bold.woff2',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
console.log(isValid); // true
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The function checks the basename, not the file's existence or font contents.
|
|
49
|
+
It returns `Promise<boolean>` and logs a console error when validation fails.
|
|
50
|
+
|
|
51
|
+
| Option | Type | Default |
|
|
52
|
+
| --- | --- | --- |
|
|
53
|
+
| `file` | `string` | Required |
|
|
54
|
+
| `regex` | `string` or `RegExp` | Built-in naming pattern |
|
|
55
|
+
|
|
56
|
+
`file` must be a non-empty filename or path. `regex` replaces the default
|
|
57
|
+
pattern rather than adding a second validation step.
|
|
58
|
+
|
|
59
|
+
A custom pattern can follow your project's naming convention:
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
import { validateFontFileName } from '@archoleat/validate-font-file-name';
|
|
63
|
+
|
|
64
|
+
const isValid = await validateFontFileName({
|
|
65
|
+
file: 'body.woff2',
|
|
66
|
+
regex: /^[a-z]+\.woff2$/,
|
|
35
67
|
});
|
|
68
|
+
|
|
69
|
+
console.log(isValid); // true
|
|
36
70
|
```
|
|
37
71
|
|
|
72
|
+
An invalid regular expression throws; handle that error if the pattern comes
|
|
73
|
+
from user input.
|
|
74
|
+
|
|
38
75
|
### Naming Convention
|
|
39
76
|
|
|
40
77
|
The **font family** and **font weight** must be in **Pascal Case**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archoleat/validate-font-file-name",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "1.2.
|
|
3
|
+
"description": "Check font filenames against a naming convention in Node.js",
|
|
4
|
+
"version": "1.2.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "nikkeyl.me@gmail.com",
|
|
@@ -18,12 +18,13 @@
|
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"archoleat",
|
|
21
|
+
"font",
|
|
22
|
+
"font-filename",
|
|
23
|
+
"naming-convention",
|
|
24
|
+
"nodejs",
|
|
21
25
|
"typescript",
|
|
22
|
-
"
|
|
26
|
+
"validation"
|
|
23
27
|
],
|
|
24
|
-
"engines": {
|
|
25
|
-
"bun": ">=1.0.0"
|
|
26
|
-
},
|
|
27
28
|
"type": "module",
|
|
28
29
|
"types": "index.d.ts",
|
|
29
30
|
"imports": {
|
|
@@ -83,5 +84,11 @@
|
|
|
83
84
|
"semantic-release": "^25.0.5",
|
|
84
85
|
"tslib": "^2.8.1",
|
|
85
86
|
"typescript": "^6.0.2"
|
|
87
|
+
},
|
|
88
|
+
"patchedDependencies": {
|
|
89
|
+
"glob@10.5.0": "patches/glob@10.5.0.patch",
|
|
90
|
+
"minimatch@9.0.9": "patches/minimatch@9.0.9.patch",
|
|
91
|
+
"minimatch@10.2.6": "patches/minimatch@10.2.6.patch",
|
|
92
|
+
"npm@11.21.2": "patches/npm@11.21.2.patch"
|
|
86
93
|
}
|
|
87
94
|
}
|