Remove CoffeeScript

This commit is contained in:
Alf Eaton
2021-05-26 15:06:24 +01:00
parent 93f618a980
commit 9c0dbbc5c8
5 changed files with 19 additions and 36 deletions

View File

@@ -1,21 +1,12 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
let defaults, possibleConfigFiles, settingsExist;
const fs = require("fs");
const path = require("path");
const env = (process.env.NODE_ENV || "development").toLowerCase();
var merge = function(settings, defaults) {
for (let key in settings) {
const value = settings[key];
const merge = function(settings, defaults) {
for (const [key, value] of Object.entries(settings)) {
if ((typeof(value) === "object") && !(value instanceof Array)) {
defaults[key] = merge(settings[key], defaults[key] || {});
defaults[key] = merge(value, defaults[key] || {});
} else {
defaults[key] = value;
}
@@ -30,30 +21,30 @@ if (fs.existsSync(`${defaultSettingsPath}.js`)) {
defaults = require(`${defaultSettingsPath}.js`);
settingsExist = true;
} else if (fs.existsSync(`${defaultSettingsPath}.coffee`)) {
console.warn(`CoffeeScript settings file ${defaultSettingsPath}.coffee is deprecated, please convert to JavaScript`);
console.log(`Using default settings from ${defaultSettingsPath}.coffee`);
defaults = require(`${defaultSettingsPath}.coffee`);
settingsExist = true;
// TODO: remove this in the next major version
throw new Error(`CoffeeScript settings file ${defaultSettingsPath}.coffee is no longer supported, please convert to JavaScript`);
} else {
defaults = {};
settingsExist = false;
}
if (process.env.SHARELATEX_CONFIG != null) {
if (process.env.SHARELATEX_CONFIG) {
possibleConfigFiles = [process.env.SHARELATEX_CONFIG];
} else {
possibleConfigFiles = [
process.cwd() + `/config/settings.${env}.js`,
path.normalize(__dirname + `/../../config/settings.${env}.js`),
// TODO: remove these in the next major version
process.cwd() + `/config/settings.${env}.coffee`,
path.normalize(__dirname + `/../../config/settings.${env}.coffee`)
];
}
for (let file of Array.from(possibleConfigFiles)) {
for (let file of possibleConfigFiles) {
if (fs.existsSync(file)) {
// TODO: remove this in the next major version
if (file.endsWith('.coffee')) {
console.warn(`CoffeeScript settings file ${file} is deprecated, please convert to JavaScript`);
throw new Error(`CoffeeScript settings file ${file} is no longer supported, please convert to JavaScript`);
}
console.log("Using settings from " + file);
module.exports = merge(require(file), defaults);