From d00b62a3f57a293844aadc219c903023115da388 Mon Sep 17 00:00:00 2001 From: mariodmpereira Date: Thu, 23 Dec 2021 00:33:36 +0000 Subject: [PATCH 1/2] Add support for TypeScript (.ts) files --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index cd37da7..bf2b6f8 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ var fs = require('fs'), resolve = require('path').resolve, dirname = require('path').dirname, defaultOptions = { - extensions: ['js', 'json', 'coffee'], + extensions: ['js', 'json', 'coffee', 'ts'], recurse: true, rename: function (name) { return name; From e8306d9c7da6d1f802602645add900fb51b27878 Mon Sep 17 00:00:00 2001 From: mariodmpereira Date: Thu, 23 Dec 2021 01:02:28 +0000 Subject: [PATCH 2/2] Add test case to cover .ts files existance --- test/example/foo3.ts | 1 + test/test.js | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 test/example/foo3.ts diff --git a/test/example/foo3.ts b/test/example/foo3.ts new file mode 100644 index 0000000..6649536 --- /dev/null +++ b/test/example/foo3.ts @@ -0,0 +1 @@ +module.exports = 'foo3!'; \ No newline at end of file diff --git a/test/test.js b/test/test.js index bfbe798..8070413 100644 --- a/test/test.js +++ b/test/test.js @@ -26,6 +26,15 @@ assert.equal('be', test.bun.should); }); + test('should work with TS', function () { + //act + var test = reqdir(module, PATH_TO_EXAMPLE); + + //assert + assert.equal('foo!', test.foo); + assert.equal('foo3!', test.foo3); + }); + test('should be able to specify supported extensions', function () { //act var test = reqdir(module, PATH_TO_EXAMPLE, {extensions: ['json']});