Merge pull request #3495 from overleaf/ae-prettier-2

Upgrade Prettier to v2

GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
Alf Eaton
2021-04-14 14:17:21 +01:00
committed by Copybot
parent 930d7ba028
commit 1ebc8a79cb
582 changed files with 20382 additions and 20374 deletions

View File

@@ -28,9 +28,9 @@ const _ = require('underscore')
module.exports = ProjectRootDocManager = {
setRootDocAutomatically(project_id, callback) {
if (callback == null) {
callback = function(error) {}
callback = function (error) {}
}
return ProjectEntityHandler.getAllDocs(project_id, function(error, docs) {
return ProjectEntityHandler.getAllDocs(project_id, function (error, docs) {
if (error != null) {
return callback(error)
}
@@ -38,23 +38,23 @@ module.exports = ProjectRootDocManager = {
const jobs = _.map(
docs,
(doc, path) =>
function(cb) {
function (cb) {
if (
ProjectEntityUpdateHandler.isPathValidForRootDoc(path) &&
DocumentHelper.contentHasDocumentclass(doc.lines)
) {
async.setImmediate(function() {
async.setImmediate(function () {
cb(doc._id)
})
} else {
async.setImmediate(function() {
async.setImmediate(function () {
cb(null)
})
}
}
)
return async.series(jobs, function(root_doc_id) {
return async.series(jobs, function (root_doc_id) {
if (root_doc_id != null) {
return ProjectEntityUpdateHandler.setRootDoc(
project_id,
@@ -70,7 +70,7 @@ module.exports = ProjectRootDocManager = {
findRootDocFileFromDirectory(directoryPath, callback) {
if (callback == null) {
callback = function(error, path, content) {}
callback = function (error, path, content) {}
}
const filePathsPromise = globby(['**/*.{tex,Rtex}'], {
cwd: directoryPath,
@@ -88,7 +88,7 @@ module.exports = ProjectRootDocManager = {
ProjectRootDocManager._sortFileList(
unsortedFiles,
directoryPath,
function(err, files) {
function (err, files) {
if (err != null) {
return callback(err)
}
@@ -96,12 +96,12 @@ module.exports = ProjectRootDocManager = {
return async.until(
() => doc != null || files.length === 0,
function(cb) {
function (cb) {
const file = files.shift()
return fs.readFile(
Path.join(directoryPath, file),
'utf8',
function(error, content) {
function (error, content) {
if (error != null) {
return cb(error)
}
@@ -131,11 +131,11 @@ module.exports = ProjectRootDocManager = {
setRootDocFromName(project_id, rootDocName, callback) {
if (callback == null) {
callback = function(error) {}
callback = function (error) {}
}
return ProjectEntityHandler.getAllDocPathsFromProjectById(
project_id,
function(error, docPaths) {
function (error, docPaths) {
let doc_id, path
if (error != null) {
return callback(error)
@@ -180,89 +180,91 @@ module.exports = ProjectRootDocManager = {
ensureRootDocumentIsSet(project_id, callback) {
if (callback == null) {
callback = function(error) {}
callback = function (error) {}
}
return ProjectGetter.getProject(project_id, { rootDoc_id: 1 }, function(
error,
project
) {
if (error != null) {
return callback(error)
}
if (project == null) {
return callback(new Error('project not found'))
}
return ProjectGetter.getProject(
project_id,
{ rootDoc_id: 1 },
function (error, project) {
if (error != null) {
return callback(error)
}
if (project == null) {
return callback(new Error('project not found'))
}
if (project.rootDoc_id != null) {
return callback()
} else {
return ProjectRootDocManager.setRootDocAutomatically(
project_id,
callback
)
if (project.rootDoc_id != null) {
return callback()
} else {
return ProjectRootDocManager.setRootDocAutomatically(
project_id,
callback
)
}
}
})
)
},
ensureRootDocumentIsValid(project_id, callback) {
if (callback == null) {
callback = function(error) {}
callback = function (error) {}
}
return ProjectGetter.getProject(project_id, { rootDoc_id: 1 }, function(
error,
project
) {
if (error != null) {
return callback(error)
}
if (project == null) {
return callback(new Error('project not found'))
}
return ProjectGetter.getProject(
project_id,
{ rootDoc_id: 1 },
function (error, project) {
if (error != null) {
return callback(error)
}
if (project == null) {
return callback(new Error('project not found'))
}
if (project.rootDoc_id != null) {
return ProjectEntityHandler.getAllDocPathsFromProjectById(
project_id,
function(error, docPaths) {
if (error != null) {
return callback(error)
}
let rootDocValid = false
for (let doc_id in docPaths) {
const _path = docPaths[doc_id]
if (doc_id === project.rootDoc_id) {
rootDocValid = true
if (project.rootDoc_id != null) {
return ProjectEntityHandler.getAllDocPathsFromProjectById(
project_id,
function (error, docPaths) {
if (error != null) {
return callback(error)
}
let rootDocValid = false
for (let doc_id in docPaths) {
const _path = docPaths[doc_id]
if (doc_id === project.rootDoc_id) {
rootDocValid = true
}
}
if (rootDocValid) {
return callback()
} else {
return ProjectEntityUpdateHandler.unsetRootDoc(project_id, () =>
ProjectRootDocManager.setRootDocAutomatically(
project_id,
callback
)
)
}
}
if (rootDocValid) {
return callback()
} else {
return ProjectEntityUpdateHandler.unsetRootDoc(project_id, () =>
ProjectRootDocManager.setRootDocAutomatically(
project_id,
callback
)
)
}
}
)
} else {
return ProjectRootDocManager.setRootDocAutomatically(
project_id,
callback
)
)
} else {
return ProjectRootDocManager.setRootDocAutomatically(
project_id,
callback
)
}
}
})
)
},
_sortFileList(listToSort, rootDirectory, callback) {
if (callback == null) {
callback = function(error, result) {}
callback = function (error, result) {}
}
return async.mapLimit(
listToSort,
5,
(filePath, cb) =>
fs.stat(Path.join(rootDirectory, filePath), function(err, stat) {
fs.stat(Path.join(rootDirectory, filePath), function (err, stat) {
if (err != null) {
return cb(err)
}
@@ -273,7 +275,7 @@ module.exports = ProjectRootDocManager = {
name: Path.basename(filePath)
})
}),
function(err, files) {
function (err, files) {
if (err != null) {
return callback(err)
}