mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
Migrated settings to es6
This commit is contained in:
parent
6ed711a4d8
commit
154e67315c
39 changed files with 710 additions and 702 deletions
|
@ -18,9 +18,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const log4js = require('log4js');
|
||||
const path = require('path');
|
||||
const _ = require('underscore');
|
||||
import log4js from 'log4js';
|
||||
import path from 'path';
|
||||
import _ from 'underscore';
|
||||
|
||||
const absPathLogger = log4js.getLogger('AbsolutePaths');
|
||||
|
||||
|
@ -43,8 +43,8 @@ let etherpadRoot: string|null = null;
|
|||
const popIfEndsWith = (stringArray: string[], lastDesiredElements: string[]): string[] | false => {
|
||||
if (stringArray.length <= lastDesiredElements.length) {
|
||||
absPathLogger.debug(`In order to pop "${lastDesiredElements.join(path.sep)}" ` +
|
||||
`from "${stringArray.join(path.sep)}", it should contain at least ` +
|
||||
`${lastDesiredElements.length + 1} elements`);
|
||||
`from "${stringArray.join(path.sep)}", it should contain at least ` +
|
||||
`${lastDesiredElements.length + 1} elements`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ const popIfEndsWith = (stringArray: string[], lastDesiredElements: string[]): st
|
|||
}
|
||||
|
||||
absPathLogger.debug(
|
||||
`${stringArray.join(path.sep)} does not end with "${lastDesiredElements.join(path.sep)}"`);
|
||||
`${stringArray.join(path.sep)} does not end with "${lastDesiredElements.join(path.sep)}"`);
|
||||
return false;
|
||||
};
|
||||
|
||||
|
@ -74,7 +74,7 @@ const popIfEndsWith = (stringArray: string[], lastDesiredElements: string[]): st
|
|||
* @return {string} The identified absolute base path. If such path cannot be
|
||||
* identified, prints a log and exits the application.
|
||||
*/
|
||||
exports.findEtherpadRoot = () => {
|
||||
export const findEtherpadRoot = () => {
|
||||
if (etherpadRoot != null) {
|
||||
return etherpadRoot;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ exports.findEtherpadRoot = () => {
|
|||
|
||||
if (maybeEtherpadRoot === false) {
|
||||
absPathLogger.error('Could not identity Etherpad base path in this ' +
|
||||
`${process.platform} installation in "${foundRoot}"`);
|
||||
`${process.platform} installation in "${foundRoot}"`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ exports.findEtherpadRoot = () => {
|
|||
}
|
||||
|
||||
absPathLogger.error(
|
||||
`To run, Etherpad has to identify an absolute base path. This is not: "${etherpadRoot}"`);
|
||||
`To run, Etherpad has to identify an absolute base path. This is not: "${etherpadRoot}"`);
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
|
@ -130,12 +130,12 @@ exports.findEtherpadRoot = () => {
|
|||
* it is returned unchanged. Otherwise it is interpreted
|
||||
* relative to exports.root.
|
||||
*/
|
||||
exports.makeAbsolute = (somePath: string) => {
|
||||
export const makeAbsolute = (somePath: string) => {
|
||||
if (path.isAbsolute(somePath)) {
|
||||
return somePath;
|
||||
}
|
||||
|
||||
const rewrittenPath = path.join(exports.findEtherpadRoot(), somePath);
|
||||
const rewrittenPath = path.join(findEtherpadRoot(), somePath);
|
||||
|
||||
absPathLogger.debug(`Relative path "${somePath}" can be rewritten to "${rewrittenPath}"`);
|
||||
return rewrittenPath;
|
||||
|
@ -149,7 +149,7 @@ exports.makeAbsolute = (somePath: string) => {
|
|||
* a subdirectory of the base one
|
||||
* @return {boolean}
|
||||
*/
|
||||
exports.isSubdir = (parent: string, arbitraryDir: string): boolean => {
|
||||
export const isSubdir = (parent: string, arbitraryDir: string): boolean => {
|
||||
// modified from: https://stackoverflow.com/questions/37521893/determine-if-a-path-is-subdirectory-of-another-in-node-js#45242825
|
||||
const relative = path.relative(parent, arbitraryDir);
|
||||
return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue