Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .ts (or parameterized) file extensions for loadModules #1777

Merged
merged 8 commits into from
Oct 28, 2019
9 changes: 6 additions & 3 deletions packages/botkit/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1123,10 +1123,13 @@ export class Botkit {
* ```
*
* @param p {string} path to a folder of module files
* @param exts {string[]} the extensions that you would like to load (default: ['.js', '.ts'])
O-Mutt marked this conversation as resolved.
Show resolved Hide resolved
*/
public loadModules(p: string): void {
// load all the .js files from this path
fs.readdirSync(p).filter((f) => { return (path.extname(f) === '.js'); }).forEach((file) => {
public loadModules(p: string, exts: string[] = ['.js', '.ts']): void {
O-Mutt marked this conversation as resolved.
Show resolved Hide resolved
// load all the .js|.ts files from this path
fs.readdirSync(p).filter((f) => {
return exts.includes(path.extname(f));
}).forEach((file) => {
this.loadModule(path.join(p, file));
});
}
Expand Down