mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 01:16:15 -04:00
Moved settings.js to ts.
This commit is contained in:
parent
71c74bc633
commit
fbf8667019
44 changed files with 852 additions and 760 deletions
|
@ -24,14 +24,14 @@ import {AsyncQueueTask} from "../types/AsyncQueueTask";
|
|||
|
||||
const spawn = require('child_process').spawn;
|
||||
const async = require('async');
|
||||
import {abiword} from './Settings';
|
||||
import {settings} from './Settings';
|
||||
const os = require('os');
|
||||
|
||||
// on windows we have to spawn a process for each convertion,
|
||||
// cause the plugin abicommand doesn't exist on this platform
|
||||
if (os.type().indexOf('Windows') > -1) {
|
||||
exports.convertFile = async (srcFile: string, destFile: string, type: string) => {
|
||||
const _abiword = spawn(abiword, [`--to=${destFile}`, srcFile]);
|
||||
const _abiword = spawn(settings.abiword, [`--to=${destFile}`, srcFile]);
|
||||
let stdoutBuffer = '';
|
||||
_abiword.stdout.on('data', (data: string) => { stdoutBuffer += data.toString(); });
|
||||
_abiword.stderr.on('data', (data: string) => { stdoutBuffer += data.toString(); });
|
||||
|
@ -47,12 +47,12 @@ if (os.type().indexOf('Windows') > -1) {
|
|||
};
|
||||
// on unix operating systems, we can start abiword with abicommand and
|
||||
// communicate with it via stdin/stdout
|
||||
// thats much faster, about factor 10
|
||||
// that's much faster, about factor 10
|
||||
} else {
|
||||
let _abiword: ChildProcess;
|
||||
let stdoutCallback: Function|null = null;
|
||||
const spawnAbiword = () => {
|
||||
_abiword = spawn(abiword, ['--plugin', 'AbiCommand']);
|
||||
_abiword = spawn(settings.abiword, ['--plugin', 'AbiCommand']);
|
||||
let stdoutBuffer = '';
|
||||
let firstPrompt = true;
|
||||
_abiword.stderr!.on('data', (data) => { stdoutBuffer += data.toString(); });
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const settings = require('./Settings');
|
||||
import {root, settings} from './Settings';
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
const plugins = require('../../static/js/pluginfw/plugin_defs');
|
||||
|
@ -33,7 +33,7 @@ const sanitizePathname = require('./sanitizePathname');
|
|||
|
||||
const logger = log4js.getLogger('Minify');
|
||||
|
||||
const ROOT_DIR = path.join(settings.root, 'src/static/');
|
||||
const ROOT_DIR = path.join(root, 'src/static/');
|
||||
|
||||
const threadsPool = new Threads.Pool(() => Threads.spawn(new Threads.Worker('./MinifyWorker')), 2);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
const semver = require('semver');
|
||||
const settings = require('./Settings');
|
||||
import {getEpVersion, settings} from './Settings';
|
||||
const axios = require('axios');
|
||||
const headers = {
|
||||
'User-Agent': 'Etherpad/' + settings.getEpVersion(),
|
||||
'User-Agent': 'Etherpad/' + getEpVersion(),
|
||||
}
|
||||
|
||||
type Infos = {
|
||||
|
@ -45,7 +45,7 @@ exports.getLatestVersion = () => {
|
|||
exports.needsUpdate = async (cb: Function) => {
|
||||
await loadEtherpadInformations()
|
||||
.then((info:Infos) => {
|
||||
if (semver.gt(info.latestVersion, settings.getEpVersion())) {
|
||||
if (semver.gt(info.latestVersion, getEpVersion())) {
|
||||
if (cb) return cb(true);
|
||||
}
|
||||
}).catch((err: Error) => {
|
||||
|
|
|
@ -21,7 +21,7 @@ const fs = require('fs');
|
|||
const fsp = fs.promises;
|
||||
const path = require('path');
|
||||
const zlib = require('zlib');
|
||||
const settings = require('./Settings');
|
||||
import {root} from './Settings';
|
||||
const existsSync = require('./path_exists');
|
||||
const util = require('util');
|
||||
|
||||
|
@ -40,7 +40,7 @@ const util = require('util');
|
|||
const _crypto = require('crypto');
|
||||
|
||||
|
||||
let CACHE_DIR = path.join(settings.root, 'var/');
|
||||
let CACHE_DIR = path.join(root, 'var/');
|
||||
CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined;
|
||||
|
||||
type Headers = {
|
||||
|
|
|
@ -5,11 +5,11 @@ import {ChildProcess} from "node:child_process";
|
|||
import {PromiseWithStd} from "../types/PromiseWithStd";
|
||||
import {Readable} from "node:stream";
|
||||
|
||||
import {root, settings} from "./Settings";
|
||||
|
||||
const spawn = require('cross-spawn');
|
||||
const log4js = require('log4js');
|
||||
const path = require('path');
|
||||
const settings = require('./Settings');
|
||||
|
||||
const logger = log4js.getLogger('runCmd');
|
||||
|
||||
const logLines = (readable: undefined | Readable | null, logLineFn: (arg0: (string | undefined)) => void) => {
|
||||
|
@ -77,7 +77,7 @@ const logLines = (readable: undefined | Readable | null, logLineFn: (arg0: (stri
|
|||
module.exports = exports = (args: string[], opts:RunCMDOptions = {}) => {
|
||||
logger.debug(`Executing command: ${args.join(' ')}`);
|
||||
|
||||
opts = {cwd: settings.root, ...opts};
|
||||
opts = {cwd: root, ...opts};
|
||||
logger.debug(`cwd: ${opts.cwd}`);
|
||||
|
||||
// Log stdout and stderr by default.
|
||||
|
@ -112,8 +112,8 @@ module.exports = exports = (args: string[], opts:RunCMDOptions = {}) => {
|
|||
opts.env = {
|
||||
...env, // Copy env to avoid modifying process.env or the caller's supplied env.
|
||||
[pathVarName]: [
|
||||
path.join(settings.root, 'src', 'node_modules', '.bin'),
|
||||
path.join(settings.root, 'node_modules', '.bin'),
|
||||
path.join(root, 'src', 'node_modules', '.bin'),
|
||||
path.join(root, 'node_modules', '.bin'),
|
||||
...(PATH ? PATH.split(path.delimiter) : []),
|
||||
].join(path.delimiter),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue