overleaf/services/web/modules/modules-ide.js

26 lines
556 B
JavaScript
Raw Normal View History

const fs = require('fs')
const path = require('path')
const MODULES_PATH = path.join(__dirname, './')
const entryPoints = []
if (fs.existsSync(MODULES_PATH)) {
fs.readdirSync(MODULES_PATH).reduce((acc, module) => {
const entryPath = path.join(
MODULES_PATH,
module,
'/frontend/js/ide/index.js'
)
if (fs.existsSync(entryPath)) {
acc.push(entryPath)
}
return acc
}, entryPoints)
}
module.exports = function () {
return {
code: entryPoints.map(entryPoint => `import '${entryPoint}'`).join('\n'),
}
}