mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-02 18:35:46 +00:00
Add existence check for modules dir
This commit is contained in:
parent
becb294c5c
commit
374c0f3d65
2 changed files with 48 additions and 34 deletions
services/web
|
@ -162,40 +162,41 @@ module.exports = (grunt) ->
|
|||
moduleCompileServerTasks = []
|
||||
moduleCompileUnitTestTasks = []
|
||||
moduleUnitTestTasks = []
|
||||
for module in fs.readdirSync "./modules"
|
||||
config.coffee["module_#{module}_server"] = {
|
||||
expand: true,
|
||||
flatten: false,
|
||||
cwd: "modules/#{module}/app/coffee",
|
||||
src: ['**/*.coffee'],
|
||||
dest: "modules/#{module}/app/js",
|
||||
ext: '.js'
|
||||
}
|
||||
config.coffee["module_#{module}_index"] = {
|
||||
src: "modules/#{module}/index.coffee",
|
||||
dest: "modules/#{module}/index.js"
|
||||
}
|
||||
|
||||
moduleCompileServerTasks.push "coffee:module_#{module}_server"
|
||||
moduleCompileServerTasks.push "coffee:module_#{module}_index"
|
||||
|
||||
config.coffee["module_#{module}_unit_tests"] = {
|
||||
expand: true,
|
||||
flatten: false,
|
||||
cwd: "modules/#{module}/test/unit/coffee",
|
||||
src: ['**/*.coffee'],
|
||||
dest: "modules/#{module}/test/unit/js",
|
||||
ext: '.js'
|
||||
}
|
||||
config.mochaTest["module_#{module}_unit"] = {
|
||||
src: ["modules/#{module}/test/unit/js/*.js"]
|
||||
options:
|
||||
reporter: grunt.option('reporter') or 'spec'
|
||||
grep: grunt.option("grep")
|
||||
}
|
||||
|
||||
moduleCompileUnitTestTasks.push "coffee:module_#{module}_unit_tests"
|
||||
moduleUnitTestTasks.push "mochaTest:module_#{module}_unit"
|
||||
if fs.existsSync "./modules"
|
||||
for module in fs.readdirSync "./modules"
|
||||
config.coffee["module_#{module}_server"] = {
|
||||
expand: true,
|
||||
flatten: false,
|
||||
cwd: "modules/#{module}/app/coffee",
|
||||
src: ['**/*.coffee'],
|
||||
dest: "modules/#{module}/app/js",
|
||||
ext: '.js'
|
||||
}
|
||||
config.coffee["module_#{module}_index"] = {
|
||||
src: "modules/#{module}/index.coffee",
|
||||
dest: "modules/#{module}/index.js"
|
||||
}
|
||||
|
||||
moduleCompileServerTasks.push "coffee:module_#{module}_server"
|
||||
moduleCompileServerTasks.push "coffee:module_#{module}_index"
|
||||
|
||||
config.coffee["module_#{module}_unit_tests"] = {
|
||||
expand: true,
|
||||
flatten: false,
|
||||
cwd: "modules/#{module}/test/unit/coffee",
|
||||
src: ['**/*.coffee'],
|
||||
dest: "modules/#{module}/test/unit/js",
|
||||
ext: '.js'
|
||||
}
|
||||
config.mochaTest["module_#{module}_unit"] = {
|
||||
src: ["modules/#{module}/test/unit/js/*.js"]
|
||||
options:
|
||||
reporter: grunt.option('reporter') or 'spec'
|
||||
grep: grunt.option("grep")
|
||||
}
|
||||
|
||||
moduleCompileUnitTestTasks.push "coffee:module_#{module}_unit_tests"
|
||||
moduleUnitTestTasks.push "mochaTest:module_#{module}_unit"
|
||||
|
||||
grunt.initConfig config
|
||||
|
||||
|
|
13
services/web/app/coffee/infrastructure/Modules.coffee
Normal file
13
services/web/app/coffee/infrastructure/Modules.coffee
Normal file
|
@ -0,0 +1,13 @@
|
|||
fs = require "fs"
|
||||
Path = require "path"
|
||||
|
||||
MODULE_BASE_PATH = Path.resolve(__dirname + "/../../../modules")
|
||||
|
||||
modules = []
|
||||
for mod in fs.readdirSync(MODULE_BASE_PATH)
|
||||
modules.push require(Path.join(MODULE_BASE_PATH, mod, "index"))
|
||||
|
||||
module.exports = Modules =
|
||||
applyRouter: (app) ->
|
||||
for module in modules
|
||||
module.router?.apply(app)
|
Loading…
Reference in a new issue