Skip to content

Commit 5ffd281

Browse files
authored
Merge pull request #180 from ghostdevv/fix-read
2 parents 2cc99c1 + 49d75b0 commit 5ffd281

File tree

12 files changed

+876
-807
lines changed

12 files changed

+876
-807
lines changed

.changeset/five-trees-flow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'jellycommands': patch
3+
---
4+
5+
nested files with \_ are now ignored correctly

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup PNPM
2626
uses: pnpm/[email protected]
2727
with:
28-
version: 7.0.0
28+
version: 8
2929

3030
- name: Install Dependencies
3131
run: pnpm install

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: pnpm/[email protected]
2727
id: pnpm-install
2828
with:
29-
version: 7
29+
version: 8
3030
run_install: false
3131

3232
- name: Get pnpm store directory

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "jellycommands-monorepo",
33
"private": true,
44
"license": "MIT",
5-
"packageManager": "[email protected]",
65
"devDependencies": {
76
"@changesets/cli": "^2.26.0",
87
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
@@ -22,7 +21,7 @@
2221
"test-create": "node packages/create-jellycommands/src/bin.js"
2322
},
2423
"engines": {
25-
"pnpm": "^7.0.0",
24+
"pnpm": "^8.0.0",
2625
"npm": "forbidden, use pnpm",
2726
"node": ">= 16"
2827
},

packages/jellycommands/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@types/node": "^18.14.0",
3535
"@typescript-eslint/eslint-plugin": "^5.53.0",
3636
"@typescript-eslint/parser": "^5.53.0",
37+
"desm": "^1.3.0",
3738
"discord.js": "^14.7.1",
3839
"eslint": "^8.34.0",
3940
"eslint-config-prettier": "^8.6.0",

packages/jellycommands/src/utils/files.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { basename } from 'path';
12
import { totalist } from 'totalist';
23
import { pathToFileURL } from 'url';
34

@@ -12,7 +13,9 @@ export async function read<T>(things: string | Array<string | T>, callback: (ite
1213
continue;
1314
}
1415

15-
await totalist(item, async (name, rawPath) => {
16+
await totalist(item, async (relPath, rawPath) => {
17+
const name = basename(relPath);
18+
1619
// If it starts with an _ we ignore it
1720
if (name.startsWith('_')) return;
1821

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { read } from '../../src/utils/files';
2+
import { notEqual, ok } from 'assert';
3+
import { join } from 'desm';
4+
import { test } from 'uvu';
5+
6+
const TEST_FILES = join(import.meta.url, './test-files');
7+
8+
test('can read files', async () => {
9+
const data: string[] = [];
10+
11+
await read<string>(TEST_FILES, (item) => {
12+
data.push(item);
13+
});
14+
15+
notEqual(data.length, 0);
16+
});
17+
18+
test('ignores files with _ in name', async () => {
19+
const data: string[] = [];
20+
21+
await read<string>(TEST_FILES, (item) => {
22+
data.push(item);
23+
});
24+
25+
ok(!data.includes('WRONG'));
26+
});
27+
28+
test.run();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 'correct';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 'WRONG';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 'correct';

0 commit comments

Comments
 (0)