Skip to content

Commit

Permalink
Merge pull request #1777 from Mutmatt/master
Browse files Browse the repository at this point in the history
Support .ts (or parameterized) file extensions for loadModules
  • Loading branch information
benbrown committed Oct 28, 2019
2 parents c22d360 + 9c477fc commit a4b54e7
Showing 1 changed file with 6 additions and 3 deletions.
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'])
*/
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']): void {
// 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

0 comments on commit a4b54e7

Please sign in to comment.