Skip to content

Commit

Permalink
use ignore from globby, fixes [BUG] - Config module exclude failing/n…
Browse files Browse the repository at this point in the history
…ot working as expected #68
  • Loading branch information
catplvsplus committed Oct 24, 2024
1 parent d0e2b19 commit 976d995
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
13 changes: 0 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/reciple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"dotenv": "^16.4.5",
"fallout-utility": "^2.9.1",
"globby": "^14.0.2",
"micromatch": "^4.0.8",
"prompts": "^2.4.2",
"prtyprnt": "^1.1.0",
"semver": "^7.6.3"
Expand Down
12 changes: 3 additions & 9 deletions packages/reciple/src/classes/ModuleLoader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type Awaitable, kleur } from 'fallout-utility';
import type { RecipleConfig } from '../types/structures.js';
import micromatch from 'micromatch';
import path from 'node:path';
import { existsAsync } from '@reciple/utils';
import { lstat, mkdir, readdir } from 'node:fs/promises';
Expand Down Expand Up @@ -37,13 +36,10 @@ export class ModuleLoader {
let dirs = await globby(folder, {
cwd: process.cwd(),
onlyDirectories: true,
absolute: true
absolute: true,
ignore: options.config.exclude
});

if (options.config?.exclude?.length) {
dirs = dirs.filter(f => !micromatch.isMatch(path.basename(f), options.config.exclude!));
}

paths.push(...await ModuleLoader.getModulePaths({
...options,
config: {
Expand All @@ -61,9 +57,7 @@ export class ModuleLoader {
const files = (await readdir(folderPath))
.map(file => path
.join(folderPath, file))
.filter(f => !options.config?.exclude?.length || !micromatch.isMatch(path.basename(f), options.config.exclude)
)
.filter(file => (options.filter ? options.filter(file) : ModuleLoader.defaultModulePathsFilter(file)));
.filter(file => (options.filter ? options.filter(file) : ModuleLoader.defaultModulePathsFilter(file)));

await Promise.all(files.map(async f => {
if (options.config.filter) {
Expand Down

0 comments on commit 976d995

Please sign in to comment.