@archoleat/validate-font-file-name 1.1.1 → 1.1.3
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 +10 -39
- package/index.d.ts +6 -13
- package/index.js +1 -1
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
- [Installation](#installation)
|
|
18
18
|
- [Usage](#usage)
|
|
19
|
-
- [Naming Convention](#naming-convention)
|
|
20
19
|
- [Contributing](#contributing)
|
|
21
20
|
- [License](#license)
|
|
22
21
|
|
|
@@ -28,54 +27,26 @@ bun i -D @archoleat/validate-font-file-name
|
|
|
28
27
|
|
|
29
28
|
## Usage
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
import { validateFontFileName } from '@archoleat/validate-font-file-name';
|
|
33
|
-
|
|
34
|
-
const validFontFileName = 'OpenSans-Regular.woff2';
|
|
35
|
-
const invalidFontFileName = 'OpenSans.woff2';
|
|
30
|
+
### Naming Convention
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
The **font family** and **font weight** must be in **Pascal Case**
|
|
33
|
+
and separated by a **hyphen**.
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
console.log(await validateFontFileName({ file: invalidFontFileName }));
|
|
42
|
-
```
|
|
35
|
+
Extensions that are allowed: `otf`, `ttf`, `woff`, `woff2`.
|
|
43
36
|
|
|
44
|
-
|
|
37
|
+
> Example: `OpenSans-SemiBold.woff2`.
|
|
45
38
|
|
|
46
|
-
|
|
39
|
+
It's not necessary to specify the `regex` parameter.
|
|
47
40
|
|
|
48
41
|
```js
|
|
49
42
|
import { validateFontFileName } from '@archoleat/validate-font-file-name';
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const invalidFontFileName = 'OpenSans.woff2';
|
|
56
|
-
|
|
57
|
-
// returns: true
|
|
58
|
-
console.log(await validateFontFileName({
|
|
59
|
-
file: validFontFileName,
|
|
60
|
-
regex: yourRegex,
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
// returns: {current time} [ERROR] 'OpenSans.woff2' doesn't match with '/OpenSans-regular/'.
|
|
64
|
-
console.log(await validateFontFileName({
|
|
65
|
-
file: invalidFontFileName,
|
|
66
|
-
regex: yourRegex,
|
|
67
|
-
}));
|
|
44
|
+
await validateFontFileName({
|
|
45
|
+
file: 'path/to/file',
|
|
46
|
+
regex: /regex/ | new RegExp() | '',
|
|
47
|
+
});
|
|
68
48
|
```
|
|
69
49
|
|
|
70
|
-
## Naming Convention
|
|
71
|
-
|
|
72
|
-
The **font family** and **font weight** must be in **Pascal Case**
|
|
73
|
-
and separated by a **hyphen**.
|
|
74
|
-
|
|
75
|
-
Extensions that are allowed: `otf`, `ttf`, `woff`, `woff2`.
|
|
76
|
-
|
|
77
|
-
> `{FontFamily}-{FontWeight}.{extension}`
|
|
78
|
-
|
|
79
50
|
## Contributing
|
|
80
51
|
|
|
81
52
|
Please read [**CONTRIBUTING**](https://github.com/archoleat/.github/blob/main/CONTRIBUTING.md)
|
package/index.d.ts
CHANGED
|
@@ -4,22 +4,15 @@ type Parameters = {
|
|
|
4
4
|
};
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* if a given font file name matches a specific regex.
|
|
7
|
+
* Validates the font file name.
|
|
9
8
|
*
|
|
10
|
-
* @param {string} file - The
|
|
11
|
-
* function is a string that represents the file name of a font file that
|
|
12
|
-
* you want to validate.
|
|
9
|
+
* @param {string} file - The file path of the font file.
|
|
13
10
|
*
|
|
14
|
-
* @param {string
|
|
15
|
-
*
|
|
16
|
-
* expression for validating the font file name. If a custom
|
|
17
|
-
* regex is not provided, the function uses a default regex
|
|
18
|
-
* to validate the font file name.
|
|
11
|
+
* @param {string} [regex=''] - The regular expression pattern to
|
|
12
|
+
* match the font file name.
|
|
19
13
|
*
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
22
|
-
* and `false` if it does not match.
|
|
14
|
+
* @return {boolean} - Return true if the font file name matches the
|
|
15
|
+
* specified regex pattern, false otherwise.
|
|
23
16
|
*/
|
|
24
17
|
declare const validateFontFileName: (parameters: Parameters) => Promise<boolean>;
|
|
25
18
|
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parse as
|
|
1
|
+
import{parse as a}from"node:path";import{FONT_FILE_NAME_REGEX as n}from"@archoleat/reglib";import{error as m}from"@archoleat/notifier";const c=async o=>{const{file:s,regex:e=""}=o,t=a(s).base,r=typeof e=="string"&&e!==""?new RegExp(e):e||n;return r.test(t)?!0:(await m({message:`(${t}) doesn't match with (${r})`}),!1)};export{c as validateFontFileName};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archoleat/validate-font-file-name",
|
|
3
3
|
"description": "Checking font file names for standardization",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "archoleat@gmail.com",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"type": "module",
|
|
38
38
|
"types": "index.d.ts",
|
|
39
39
|
"imports": {
|
|
40
|
-
"#
|
|
40
|
+
"#app": "./src/app.ts"
|
|
41
41
|
},
|
|
42
42
|
"exports": {
|
|
43
43
|
".": "./index.js"
|
|
@@ -55,40 +55,41 @@
|
|
|
55
55
|
"@archoleat/reglib": "^1.1.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@archoleat/commitlint-define-config": "^1.0.
|
|
59
|
-
"@archoleat/eslint-flat-compatibility": "^1.1.
|
|
60
|
-
"@archoleat/prettier-define-config": "^1.0.
|
|
61
|
-
"@archoleat/semantic-release-define-config": "^1.1.
|
|
62
|
-
"@commitlint/cli": "^19.4.
|
|
63
|
-
"@commitlint/config-conventional": "^19.
|
|
58
|
+
"@archoleat/commitlint-define-config": "^1.0.11",
|
|
59
|
+
"@archoleat/eslint-flat-compatibility": "^1.1.8",
|
|
60
|
+
"@archoleat/prettier-define-config": "^1.0.2",
|
|
61
|
+
"@archoleat/semantic-release-define-config": "^1.1.16",
|
|
62
|
+
"@commitlint/cli": "^19.4.1",
|
|
63
|
+
"@commitlint/config-conventional": "^19.4.1",
|
|
64
64
|
"@commitlint/types": "^19.0.3",
|
|
65
65
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
66
66
|
"@semantic-release/changelog": "^6.0.3",
|
|
67
67
|
"@semantic-release/git": "^10.0.1",
|
|
68
|
-
"@types/node": "^22.
|
|
68
|
+
"@types/node": "^22.5.2",
|
|
69
69
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
70
70
|
"@typescript-eslint/parser": "^7.18.0",
|
|
71
71
|
"@vitest/coverage-v8": "^2.0.5",
|
|
72
72
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
73
73
|
"editorconfig-checker": "^5.1.8",
|
|
74
74
|
"eslint": "^8.57.0",
|
|
75
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
75
76
|
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
76
77
|
"eslint-config-prettier": "^9.1.0",
|
|
77
78
|
"eslint-define-config": "^2.1.0",
|
|
78
|
-
"eslint-import-resolver-typescript": "^3.6.
|
|
79
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
|
79
80
|
"eslint-plugin-import": "^2.29.1",
|
|
80
81
|
"eslint-plugin-unicorn": "^55.0.0",
|
|
81
82
|
"git-pull-run": "^1.4.0",
|
|
82
83
|
"globals": "^15.9.0",
|
|
83
|
-
"husky": "^9.1.
|
|
84
|
-
"lint-staged": "^15.2.
|
|
84
|
+
"husky": "^9.1.5",
|
|
85
|
+
"lint-staged": "^15.2.10",
|
|
85
86
|
"prettier": "^3.3.3",
|
|
86
87
|
"remark": "15.0.1",
|
|
87
88
|
"remark-cli": "^12.0.1",
|
|
88
89
|
"remark-preset-lint-consistent": "^6.0.0",
|
|
89
90
|
"remark-preset-lint-markdown-style-guide": "^6.0.0",
|
|
90
91
|
"remark-preset-lint-recommended": "^7.0.0",
|
|
91
|
-
"rollup": "^4.21.
|
|
92
|
+
"rollup": "^4.21.2",
|
|
92
93
|
"rollup-plugin-dts": "^6.1.1",
|
|
93
94
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
94
95
|
"semantic-release": "^24.1.0",
|