utils/AbsolutePaths.js: do not break when running as a Windows manual install
A Windows manual install has the same directory layout of a normal Unix one (e.g. the nice symlink node_modules/ep_etherpad-lite -> ../src). Only when running from the pre-built Windows package the directory layout is different (e.g. src is physically copied into node_modules/ep_etherpad-lite). The previous version of the code wrongly assumed that all Windows installs would be run from the pre-built pakage. In this version the path search is the same on all platform. If it fails, and we are on Windows, there is a fallback for the specific case of the pre-built package. Fixes #3550
This commit is contained in:
parent
78c057af31
commit
631b23f7a2
1 changed files with 16 additions and 15 deletions
|
@ -61,8 +61,8 @@ var popIfEndsWith = function(stringArray, lastDesiredElements) {
|
||||||
* Heuristically computes the directory in which Etherpad is installed.
|
* Heuristically computes the directory in which Etherpad is installed.
|
||||||
*
|
*
|
||||||
* All the relative paths have to be interpreted against this absolute base
|
* All the relative paths have to be interpreted against this absolute base
|
||||||
* path. Since the Unix and Windows install have a different layout on disk,
|
* path. Since the Windows package install has a different layout on disk, it is
|
||||||
* they are treated as two special cases.
|
* dealt with as a special case.
|
||||||
*
|
*
|
||||||
* The path is computed only on first invocation. Subsequent invocations return
|
* The path is computed only on first invocation. Subsequent invocations return
|
||||||
* a cached value.
|
* a cached value.
|
||||||
|
@ -79,26 +79,27 @@ exports.findEtherpadRoot = function() {
|
||||||
|
|
||||||
const findRoot = require('find-root');
|
const findRoot = require('find-root');
|
||||||
const foundRoot = findRoot(__dirname);
|
const foundRoot = findRoot(__dirname);
|
||||||
|
const splitFoundRoot = foundRoot.split(path.sep);
|
||||||
|
|
||||||
var directoriesToStrip;
|
/*
|
||||||
if (process.platform === 'win32') {
|
* On Unix platforms and on Windows manual installs, foundRoot's value will
|
||||||
|
* be:
|
||||||
|
*
|
||||||
|
* <BASE_DIR>\src
|
||||||
|
*/
|
||||||
|
var maybeEtherpadRoot = popIfEndsWith(splitFoundRoot, ['src']);
|
||||||
|
|
||||||
|
if ((maybeEtherpadRoot === false) && (process.platform === 'win32')) {
|
||||||
/*
|
/*
|
||||||
* Given the structure of our Windows package, foundRoot's value
|
* If we did not find the path we are expecting, and we are running under
|
||||||
* will be the following on win32:
|
* Windows, we may still be running from a prebuilt package, whose directory
|
||||||
|
* structure is different:
|
||||||
*
|
*
|
||||||
* <BASE_DIR>\node_modules\ep_etherpad-lite
|
* <BASE_DIR>\node_modules\ep_etherpad-lite
|
||||||
*/
|
*/
|
||||||
directoriesToStrip = ['node_modules', 'ep_etherpad-lite'];
|
maybeEtherpadRoot = popIfEndsWith(splitFoundRoot, ['node_modules', 'ep_etherpad-lite']);
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* On Unix platforms, foundRoot's value will be:
|
|
||||||
*
|
|
||||||
* <BASE_DIR>\src
|
|
||||||
*/
|
|
||||||
directoriesToStrip = ['src'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const maybeEtherpadRoot = popIfEndsWith(foundRoot.split(path.sep), directoriesToStrip);
|
|
||||||
if (maybeEtherpadRoot === false) {
|
if (maybeEtherpadRoot === false) {
|
||||||
absPathLogger.error(`Could not identity Etherpad base path in this ${process.platform} installation in "${foundRoot}"`);
|
absPathLogger.error(`Could not identity Etherpad base path in this ${process.platform} installation in "${foundRoot}"`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
Loading…
Reference in a new issue