mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-18 07:40:51 +00:00
Decaf cleanup: remove __guard__
This commit is contained in:
parent
99648341e2
commit
f650da8675
1 changed files with 9 additions and 34 deletions
|
@ -8,7 +8,6 @@
|
||||||
// Fix any style issues and re-enable lint.
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS103: Rewrite code to no longer use __guard__
|
|
||||||
* DS205: Consider reworking code to avoid use of IIFEs
|
* DS205: Consider reworking code to avoid use of IIFEs
|
||||||
* DS207: Consider shorter variations of null checks
|
* DS207: Consider shorter variations of null checks
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
@ -28,10 +27,9 @@ const _ = require('lodash')
|
||||||
logger.info('using docker runner')
|
logger.info('using docker runner')
|
||||||
|
|
||||||
const usingSiblingContainers = () =>
|
const usingSiblingContainers = () =>
|
||||||
__guard__(
|
Settings != null &&
|
||||||
Settings != null ? Settings.path : undefined,
|
Settings.path != null &&
|
||||||
(x) => x.sandboxedCompilesHostDir
|
Settings.path.sandboxedCompilesHostDir != null
|
||||||
) != null
|
|
||||||
|
|
||||||
let containerMonitorTimeout
|
let containerMonitorTimeout
|
||||||
let containerMonitorInterval
|
let containerMonitorInterval
|
||||||
|
@ -76,9 +74,7 @@ module.exports = DockerRunner = {
|
||||||
volumes[directory] = '/compile'
|
volumes[directory] = '/compile'
|
||||||
|
|
||||||
command = command.map((arg) =>
|
command = command.map((arg) =>
|
||||||
__guardMethod__(arg.toString(), 'replace', (o) =>
|
arg.toString().replace('$COMPILE_DIR', '/compile')
|
||||||
o.replace('$COMPILE_DIR', '/compile')
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
;({ image } = Settings.clsi.docker)
|
;({ image } = Settings.clsi.docker)
|
||||||
|
@ -148,11 +144,8 @@ module.exports = DockerRunner = {
|
||||||
container.kill(function (error) {
|
container.kill(function (error) {
|
||||||
if (
|
if (
|
||||||
error != null &&
|
error != null &&
|
||||||
__guardMethod__(
|
error.message != null &&
|
||||||
error != null ? error.message : undefined,
|
error.message.match(/Cannot kill container .* is not running/)
|
||||||
'match',
|
|
||||||
(o) => o.match(/Cannot kill container .* is not running/)
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
{ err: error, container_id },
|
{ err: error, container_id },
|
||||||
|
@ -230,10 +223,9 @@ module.exports = DockerRunner = {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
containerReturned = true
|
containerReturned = true
|
||||||
__guard__(
|
if (options != null && options.HostConfig != null) {
|
||||||
options != null ? options.HostConfig : undefined,
|
options.HostConfig.SecurityOpt = null
|
||||||
(x) => (x.SecurityOpt = null)
|
}
|
||||||
) // small log line
|
|
||||||
logger.log({ err, exitCode, options }, 'docker container has exited')
|
logger.log({ err, exitCode, options }, 'docker container has exited')
|
||||||
callbackIfFinished()
|
callbackIfFinished()
|
||||||
})
|
})
|
||||||
|
@ -718,20 +710,3 @@ module.exports = DockerRunner = {
|
||||||
}
|
}
|
||||||
|
|
||||||
DockerRunner.startContainerMonitor()
|
DockerRunner.startContainerMonitor()
|
||||||
|
|
||||||
function __guard__(value, transform) {
|
|
||||||
return typeof value !== 'undefined' && value !== null
|
|
||||||
? transform(value)
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
function __guardMethod__(obj, methodName, transform) {
|
|
||||||
if (
|
|
||||||
typeof obj !== 'undefined' &&
|
|
||||||
obj !== null &&
|
|
||||||
typeof obj[methodName] === 'function'
|
|
||||||
) {
|
|
||||||
return transform(obj, methodName)
|
|
||||||
} else {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue