|
|
@@ -10,7 +10,6 @@
|
|
|
/*
|
|
|
* decaffeinate suggestions:
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
- * DS103: Rewrite code to no longer use __guard__
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
*/
|
|
|
@@ -35,59 +34,52 @@ const COMPILE_TIMEOUT_MS = 10 * 60 * 1000
|
|
|
|
|
|
module.exports = CompileController = {
|
|
|
compile(req, res, next) {
|
|
|
- if (next == null) {
|
|
|
- next = function(error) {}
|
|
|
- }
|
|
|
res.setTimeout(COMPILE_TIMEOUT_MS)
|
|
|
const project_id = req.params.Project_id
|
|
|
- const isAutoCompile = !!(req.query != null
|
|
|
- ? req.query.auto_compile
|
|
|
- : undefined)
|
|
|
+ const isAutoCompile = !!req.query.auto_compile
|
|
|
const user_id = AuthenticationController.getLoggedInUserId(req)
|
|
|
const options = {
|
|
|
isAutoCompile
|
|
|
}
|
|
|
- if ((req.body != null ? req.body.rootDoc_id : undefined) != null) {
|
|
|
+
|
|
|
+ if (req.body.rootDoc_id) {
|
|
|
options.rootDoc_id = req.body.rootDoc_id
|
|
|
} else if (
|
|
|
- __guard__(
|
|
|
- req.body != null ? req.body.settingsOverride : undefined,
|
|
|
- x => x.rootDoc_id
|
|
|
- ) != null
|
|
|
+ req.body.settingsOverride &&
|
|
|
+ req.body.settingsOverride.rootDoc_id
|
|
|
) {
|
|
|
// Can be removed after deploy
|
|
|
options.rootDoc_id = req.body.settingsOverride.rootDoc_id
|
|
|
}
|
|
|
- if (req.body != null ? req.body.compiler : undefined) {
|
|
|
+ if (req.body.compiler) {
|
|
|
options.compiler = req.body.compiler
|
|
|
}
|
|
|
- if (req.body != null ? req.body.draft : undefined) {
|
|
|
+ if (req.body.draft) {
|
|
|
options.draft = req.body.draft
|
|
|
}
|
|
|
- if (
|
|
|
- ['validate', 'error', 'silent'].includes(
|
|
|
- req.body != null ? req.body.check : undefined
|
|
|
- )
|
|
|
- ) {
|
|
|
+ if (['validate', 'error', 'silent'].includes(req.body.check)) {
|
|
|
options.check = req.body.check
|
|
|
}
|
|
|
- if (req.body != null ? req.body.incrementalCompilesEnabled : undefined) {
|
|
|
+ if (req.body.incrementalCompilesEnabled) {
|
|
|
options.incrementalCompilesEnabled = true
|
|
|
}
|
|
|
- return CompileManager.compile(project_id, user_id, options, function(
|
|
|
- error,
|
|
|
- status,
|
|
|
- outputFiles,
|
|
|
- clsiServerId,
|
|
|
- limits,
|
|
|
- validationProblems
|
|
|
- ) {
|
|
|
- if (error != null) {
|
|
|
- return next(error)
|
|
|
- }
|
|
|
- res.contentType('application/json')
|
|
|
- return res.status(200).send(
|
|
|
- JSON.stringify({
|
|
|
+
|
|
|
+ CompileManager.compile(
|
|
|
+ project_id,
|
|
|
+ user_id,
|
|
|
+ options,
|
|
|
+ (
|
|
|
+ error,
|
|
|
+ status,
|
|
|
+ outputFiles,
|
|
|
+ clsiServerId,
|
|
|
+ limits,
|
|
|
+ validationProblems
|
|
|
+ ) => {
|
|
|
+ if (error) {
|
|
|
+ return next(error)
|
|
|
+ }
|
|
|
+ res.json({
|
|
|
status,
|
|
|
outputFiles,
|
|
|
compileGroup: limits != null ? limits.compileGroup : undefined,
|
|
|
@@ -95,8 +87,8 @@ module.exports = CompileController = {
|
|
|
validationProblems,
|
|
|
pdfDownloadDomain: Settings.pdfDownloadDomain
|
|
|
})
|
|
|
- )
|
|
|
- })
|
|
|
+ }
|
|
|
+ )
|
|
|
},
|
|
|
|
|
|
stopCompile(req, res, next) {
|
|
|
@@ -540,9 +532,3 @@ module.exports = CompileController = {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-function __guard__(value, transform) {
|
|
|
- return typeof value !== 'undefined' && value !== null
|
|
|
- ? transform(value)
|
|
|
- : undefined
|
|
|
-}
|