From 6547954eccf6a7c4b9f4d465f1777d994375fbe7 Mon Sep 17 00:00:00 2001 From: George Date: Sat, 10 Oct 2020 01:32:44 -0400 Subject: [PATCH] Fix dotfile ignore regression in addCommandDir --- src/Client.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Client.ts b/src/Client.ts index db43bdd..874269c 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -228,13 +228,22 @@ export class Client extends Eris.Client implements ClientOptions { return this; } - /** Load the files in a directory and attempt to add a command from each. */ + /** + * Load the files in a directory and attempt to add a command from each. + * Searches recursively through directories, but ignores files and nested + * directories whose names begin with a period. + */ addCommandDir (dirname: string): this { // Synchronous calls are fine with this method because it's only called // on init // eslint-disable-next-line no-sync const filenames = fs.readdirSync(dirname); for (const filename of filenames) { + // ignore files/directories that are disabled with a leading dot + if (filename.startsWith('.')) { + continue; + } + const filepath = path.resolve(dirname, filename); // eslint-disable-next-line no-sync const info = fs.statSync(filepath);