@stonyx/utils 0.2.0 → 0.2.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/.github/workflows/ci.yml +8 -3
- package/package.json +5 -5
- package/src/date.js +4 -2
- package/src/file.js +16 -1
- package/src/plurarize.js +1 -3
package/.github/workflows/ci.yml
CHANGED
|
@@ -18,14 +18,19 @@ jobs:
|
|
|
18
18
|
- name: Checkout code
|
|
19
19
|
uses: actions/checkout@v3
|
|
20
20
|
|
|
21
|
+
- name: Setup pnpm
|
|
22
|
+
uses: pnpm/action-setup@v4
|
|
23
|
+
with:
|
|
24
|
+
version: 9
|
|
25
|
+
|
|
21
26
|
- name: Set up Node.js
|
|
22
27
|
uses: actions/setup-node@v3
|
|
23
28
|
with:
|
|
24
29
|
node-version: 22.18.0
|
|
25
|
-
cache: '
|
|
30
|
+
cache: 'pnpm'
|
|
26
31
|
|
|
27
32
|
- name: Install dependencies
|
|
28
|
-
run:
|
|
33
|
+
run: pnpm i
|
|
29
34
|
|
|
30
35
|
- name: Run tests
|
|
31
|
-
run:
|
|
36
|
+
run: pnpm test
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"keywords": [
|
|
4
4
|
"stonyx-module"
|
|
5
5
|
],
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.1",
|
|
7
7
|
"description": "Utils module for Stonyx Framework",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
"./promise": "./src/promise.js",
|
|
14
14
|
"./string": "./src/string.js"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"test": "qunit"
|
|
18
|
-
},
|
|
19
16
|
"author": "Stone Costa",
|
|
20
17
|
"license": "Apache-2.0",
|
|
21
18
|
"contributors": [
|
|
@@ -25,5 +22,8 @@
|
|
|
25
22
|
"fs": "^0.0.1-security",
|
|
26
23
|
"qunit": "^2.24.1",
|
|
27
24
|
"sinon": "^21.0.0"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "qunit"
|
|
28
28
|
}
|
|
29
|
-
}
|
|
29
|
+
}
|
package/src/date.js
CHANGED
package/src/file.js
CHANGED
|
@@ -107,11 +107,26 @@ export async function forEachFileImport(dir, callback, options={}) {
|
|
|
107
107
|
const filePath = path.join(dir, file);
|
|
108
108
|
const stats = await fsp.stat(filePath);
|
|
109
109
|
|
|
110
|
+
if (options.recursive && stats.isDirectory()) {
|
|
111
|
+
const newOptions = { ...options };
|
|
112
|
+
|
|
113
|
+
if (options.recursiveNaming) {
|
|
114
|
+
const pathPrefix = options.rawName ? file : `${kebabCaseToCamelCase(file)}`;
|
|
115
|
+
newOptions.namePrefix = options.namePrefix ? `${options.namePrefix}${pathPrefix}/` : `${pathPrefix}/`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await forEachFileImport(filePath, callback, newOptions);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
|
|
110
122
|
if (!stats.isFile() || !file.endsWith('.js')) continue;
|
|
111
123
|
|
|
112
124
|
const prefix = process.platform === 'win32' ? 'file://' : '';
|
|
113
125
|
const rawName = file.replace('.js', '');
|
|
114
|
-
|
|
126
|
+
let name = options.rawName ? rawName : kebabCaseToCamelCase(rawName);
|
|
127
|
+
|
|
128
|
+
if (options.namePrefix) name = `${options.namePrefix}${name}`;
|
|
129
|
+
|
|
115
130
|
const exported = await import(prefix + path.resolve(filePath));
|
|
116
131
|
const output = !options.fullExport ? exported.default : exported;
|
|
117
132
|
|
package/src/plurarize.js
CHANGED
|
@@ -83,9 +83,7 @@ const rules = [
|
|
|
83
83
|
|
|
84
84
|
// --- Exported pluralizer ---
|
|
85
85
|
export default function pluralize(word) {
|
|
86
|
-
if (typeof word !== 'string' || !/^[a-zA-Z]+$/.test(word))
|
|
87
|
-
throw new Error('Input must be a single word containing only letters.');
|
|
88
|
-
}
|
|
86
|
+
if (typeof word !== 'string' || !/^[a-zA-Z]+$/.test(word)) return word;
|
|
89
87
|
|
|
90
88
|
const lower = word.toLowerCase();
|
|
91
89
|
|