I'm using TypeScript and have all of my JS files compiled to ./dist/
. I want to enumerate these JS files and write a line to ./index.js
for each file:
module.exports.{filename} = require("./dist/{filename}").{filename};
Example:
module.exports.MyClass1 = require("./dist/MyClass1").MyClass1;
module.exports.MyClass2 = require("./dist/MyClass2").MyClass2;
module.exports.MyClass3 = require("./dist/MyClass3").MyClass3;
// ... etc. ...
This would auto-export all of my classes so that I don't have to do it by hand. I need to implement this as a gulp task, but I'm not exactly sure how to go about it.