overleaf/services/web/app/coffee/Features/Project/V1ProjectGetter.coffee

21 lines
957 B
CoffeeScript
Raw Normal View History

fs = require 'fs'
path = require 'path'
2017-10-30 05:42:12 -04:00
logger = require 'logger-sharelatex'
2017-10-25 04:13:17 -04:00
INTEGRATION_MODULE_PATH = path.resolve(__dirname, '../../../../modules/overleaf-integration-web-module')
2017-10-25 04:13:17 -04:00
V1ProjectGetter =
# Default implementation is a no-op
2017-10-25 04:13:17 -04:00
findAllUsersProjects: (userId, callback = (error, projects) ->) ->
logger.log {}, "integration modules doesn't exist, not loading V1 projects"
return callback()
fs.stat INTEGRATION_MODULE_PATH, (error, stats) ->
return if error? or !stats.isDirectory()
2017-11-03 06:23:29 -04:00
logger.log {isDirectory: stats.isDirectory()}, "integration module does exist, loading V1 projects"
# Monkey patch impl to actually fetch projects
V1ProjectGetter.findAllUsersProjects = (userId, callback = (error, projects) ->) ->
IntegrationProjectListGetter = require(path.join(INTEGRATION_MODULE_PATH, 'app/coffee/ProjectList/ProjectListGetter'))
IntegrationProjectListGetter.findAllUsersProjects(userId, callback)
module.exports = V1ProjectGetter