decaffeinate: Run post-processing cleanups on CommandRunner.coffee and 25 other files

This commit is contained in:
decaffeinate 2020-02-19 12:14:28 +01:00 committed by mserranom
parent 4eab36e3d5
commit beb6100e25
26 changed files with 206 additions and 36 deletions

View file

@ -1,3 +1,5 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS207: Consider shorter variations of null checks

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from

View file

@ -1,3 +1,12 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-return-assign,
no-undef,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
@ -88,13 +97,13 @@ module.exports = (CompileManager = {
// only run chktex on LaTeX files (not knitr .Rtex files or any others)
const isLaTeXFile = request.rootResourcePath != null ? request.rootResourcePath.match(/\.tex$/i) : undefined;
if ((request.check != null) && isLaTeXFile) {
env['CHKTEX_OPTIONS'] = '-nall -e9 -e10 -w15 -w16';
env['CHKTEX_ULIMIT_OPTIONS'] = '-t 5 -v 64000';
env.CHKTEX_OPTIONS = '-nall -e9 -e10 -w15 -w16';
env.CHKTEX_ULIMIT_OPTIONS = '-t 5 -v 64000';
if (request.check === 'error') {
env['CHKTEX_EXIT_ON_ERROR'] = 1;
env.CHKTEX_EXIT_ON_ERROR = 1;
}
if (request.check === 'validate') {
env['CHKTEX_VALIDATE'] = 1;
env.CHKTEX_VALIDATE = 1;
}
}
@ -337,7 +346,7 @@ module.exports = (CompileManager = {
_parseSynctexFromCodeOutput(output) {
const results = [];
for (let line of Array.from(output.split("\n"))) {
for (const line of Array.from(output.split("\n"))) {
const [node, page, h, v, width, height] = Array.from(line.split("\t"));
if (node === "NODE") {
results.push({
@ -412,37 +421,37 @@ module.exports = (CompileManager = {
errors: 0,
messages: ""
};
for (let line of Array.from(output.split("\n"))) {
for (const line of Array.from(output.split("\n"))) {
const [data, info] = Array.from(line.split(":"));
if (data.indexOf("Encoding") > -1) {
results['encode'] = info.trim();
results.encode = info.trim();
}
if (data.indexOf("in text") > -1) {
results['textWords'] = parseInt(info, 10);
results.textWords = parseInt(info, 10);
}
if (data.indexOf("in head") > -1) {
results['headWords'] = parseInt(info, 10);
results.headWords = parseInt(info, 10);
}
if (data.indexOf("outside") > -1) {
results['outside'] = parseInt(info, 10);
results.outside = parseInt(info, 10);
}
if (data.indexOf("of head") > -1) {
results['headers'] = parseInt(info, 10);
results.headers = parseInt(info, 10);
}
if (data.indexOf("Number of floats/tables/figures") > -1) {
results['elements'] = parseInt(info, 10);
results.elements = parseInt(info, 10);
}
if (data.indexOf("Number of math inlines") > -1) {
results['mathInline'] = parseInt(info, 10);
results.mathInline = parseInt(info, 10);
}
if (data.indexOf("Number of math displayed") > -1) {
results['mathDisplay'] = parseInt(info, 10);
results.mathDisplay = parseInt(info, 10);
}
if (data === "(errors") { // errors reported as (errors:123)
results['errors'] = parseInt(info, 10);
results.errors = parseInt(info, 10);
}
if (line.indexOf("!!! ") > -1) { // errors logged as !!! message !!!
results['messages'] += line + "\n";
results.messages += line + "\n";
}
}
return results;

View file

@ -1,3 +1,8 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
let ContentTypeMapper;
const Path = require('path');

View file

@ -1,3 +1,5 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns

View file

@ -1,3 +1,8 @@
/* eslint-disable
handle-callback-err,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from

View file

@ -1,3 +1,11 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-return-assign,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
@ -164,7 +172,7 @@ module.exports = (DockerRunner = {
// merge settings and environment parameter
const env = {};
for (let src of [Settings.clsi.docker.env, environment || {}]) {
for (const src of [Settings.clsi.docker.env, environment || {}]) {
for (key in src) { value = src[key]; env[key] = value; }
}
// set the path based on the image year
@ -173,7 +181,7 @@ module.exports = (DockerRunner = {
} else {
year = "2014";
}
env['PATH'] = `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/${year}/bin/x86_64-linux/`;
env.PATH = `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/${year}/bin/x86_64-linux/`;
const options = {
"Cmd" : command,
"Image" : image,
@ -208,7 +216,7 @@ module.exports = (DockerRunner = {
if ((Settings.path != null ? Settings.path.synctexBinHostPath : undefined) != null) {
options["HostConfig"]["Binds"].push(`${Settings.path.synctexBinHostPath}:/opt/synctex:ro`);
options.HostConfig.Binds.push(`${Settings.path.synctexBinHostPath}:/opt/synctex:ro`);
}
if (Settings.clsi.docker.seccomp_profile != null) {
@ -254,7 +262,7 @@ module.exports = (DockerRunner = {
})
;
const jobs = [];
for (let vol in volumes) {
for (const vol in volumes) {
(vol => jobs.push(cb => checkVolume(vol, cb)))(vol);
}
return async.series(jobs, callback);
@ -434,7 +442,7 @@ module.exports = (DockerRunner = {
return dockerode.listContainers({all: true}, function(error, containers) {
if (error != null) { return callback(error); }
const jobs = [];
for (let container of Array.from(containers || [])) {
for (const container of Array.from(containers || [])) {
(container =>
DockerRunner.examineOldContainer(container, function(err, name, id, ttl) {
if ((name.slice(0, 9) === '/project-') && (ttl <= 0)) {

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-useless-escape,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns

View file

@ -1,3 +1,9 @@
/* eslint-disable
no-proto,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
let Errors;
var NotFoundError = function(message) {
const error = new Error(message);

View file

@ -1,3 +1,11 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-return-assign,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns

View file

@ -1,3 +1,11 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-return-assign,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from

View file

@ -1,3 +1,9 @@
/* eslint-disable
handle-callback-err,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from

View file

@ -1,2 +1,4 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
module.exports = require("metrics-sharelatex");

View file

@ -1,3 +1,8 @@
/* eslint-disable
handle-callback-err,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from

View file

@ -1,3 +1,11 @@
/* eslint-disable
handle-callback-err,
no-return-assign,
no-unused-vars,
no-useless-escape,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
@ -17,7 +25,7 @@ module.exports = (OutputFileFinder = {
findOutputFiles(resources, directory, callback) {
if (callback == null) { callback = function(error, outputFiles, allFiles) {}; }
const incomingResources = {};
for (let resource of Array.from(resources)) {
for (const resource of Array.from(resources)) {
incomingResources[resource.path] = true;
}
@ -28,7 +36,7 @@ module.exports = (OutputFileFinder = {
return callback(error);
}
const outputFiles = [];
for (let file of Array.from(allFiles)) {
for (const file of Array.from(allFiles)) {
if (!incomingResources[file]) {
outputFiles.push({
path: file,

View file

@ -1,3 +1,12 @@
/* eslint-disable
handle-callback-err,
no-return-assign,
no-undef,
no-unused-vars,
node/no-deprecated-api,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns

View file

@ -1,3 +1,9 @@
/* eslint-disable
camelcase,
handle-callback-err,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from

View file

@ -1,3 +1,14 @@
/* eslint-disable
handle-callback-err,
no-control-regex,
no-throw-literal,
no-unused-vars,
no-useless-escape,
standard/no-callback-literal,
valid-typeof,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
@ -172,7 +183,7 @@ module.exports = (RequestParser = {
_checkPath(path) {
// check that the request does not use a relative path
for (let dir of Array.from(path.split('/'))) {
for (const dir of Array.from(path.split('/'))) {
if (dir === '..') {
throw "relative path in root resource";
}

View file

@ -1,3 +1,9 @@
/* eslint-disable
handle-callback-err,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
@ -62,10 +68,10 @@ module.exports = (ResourceStateManager = {
if (bytesRead === size) {
logger.error({file:stateFile, size, bytesRead}, "project state file truncated");
}
const array = __guard__(result != null ? result.toString() : undefined, x => x.split("\n")) || [],
adjustedLength = Math.max(array.length, 1),
resourceList = array.slice(0, adjustedLength - 1),
oldState = array[adjustedLength - 1];
const array = __guard__(result != null ? result.toString() : undefined, x => x.split("\n")) || [];
const adjustedLength = Math.max(array.length, 1);
const resourceList = array.slice(0, adjustedLength - 1);
const oldState = array[adjustedLength - 1];
const newState = `stateHash:${state}`;
logger.log({state, oldState, basePath, stateMatches: (newState === oldState)}, "checking sync state");
if (newState !== oldState) {
@ -82,7 +88,7 @@ module.exports = (ResourceStateManager = {
let file;
if (callback == null) { callback = function(error) {}; }
for (file of Array.from(resources || [])) {
for (let dir of Array.from(__guard__(file != null ? file.path : undefined, x => x.split('/')))) {
for (const dir of Array.from(__guard__(file != null ? file.path : undefined, x => x.split('/')))) {
if (dir === '..') {
return callback(new Error("relative path in resource file list"));
}

View file

@ -1,3 +1,12 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-return-assign,
no-unused-vars,
no-useless-escape,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
@ -105,7 +114,7 @@ module.exports = (ResourceWriter = {
if (error != null) { return callback(error); }
const jobs = [];
for (let file of Array.from(outputFiles || [])) {
for (const file of Array.from(outputFiles || [])) {
(function(file) {
const { path } = file;
let should_delete = true;

View file

@ -1,3 +1,10 @@
/* eslint-disable
handle-callback-err,
no-unused-vars,
node/no-deprecated-api,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from

View file

@ -1,3 +1,11 @@
/* eslint-disable
camelcase,
no-cond-assign,
no-unused-vars,
node/no-deprecated-api,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
@ -28,7 +36,7 @@ module.exports = (ForbidSymlinks = function(staticFn, root, options) {
return res.sendStatus(404);
}
// check that the file does not use a relative path
for (let dir of Array.from(file.split('/'))) {
for (const dir of Array.from(file.split('/'))) {
if (dir === '..') {
logger.warn({path}, "attempt to use a relative path");
return res.sendStatus(404);

View file

@ -1,3 +1,9 @@
/* eslint-disable
handle-callback-err,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
@ -21,7 +27,7 @@ module.exports = (TikzManager = {
checkMainFile(compileDir, mainFile, resources, callback) {
// if there's already an output.tex file, we don't want to touch it
if (callback == null) { callback = function(error, needsMainFile) {}; }
for (let resource of Array.from(resources)) {
for (const resource of Array.from(resources)) {
if (resource.path === "output.tex") {
logger.log({compileDir, mainFile}, "output.tex already in resources");
return callback(null, false);

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from

View file

@ -1,3 +1,11 @@
/* eslint-disable
handle-callback-err,
no-return-assign,
no-unused-vars,
node/no-deprecated-api,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns

View file

@ -1,3 +1,8 @@
/* eslint-disable
no-console,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns