fix basedir

pull/4/head
Cameron Clough 2022-03-21 20:02:10 +00:00
parent 6707bff659
commit 1c1b8f66c8
No known key found for this signature in database
GPG Key ID: BFB3B74B026ED43F
2 changed files with 15 additions and 2 deletions

View File

@ -21,7 +21,13 @@ function mkDirByPathSync(targetDir, { isRelativeToScript = false } = {}) {
const { sep } = path;
const initDir = path.isAbsolute(targetDir) ? sep : '';
const baseDir = isRelativeToScript ? __dirname : '.';
let baseDir;
if (isRelativeToScript) {
// retropilot-server/dist/server/controllers/../../.. => retropilot-server
baseDir = path.join(__dirname, '..', '..', '..');
} else {
baseDir = '.';
}
return targetDir.split(sep).reduce((parentDir, childDir) => {
const curDir = path.resolve(baseDir, parentDir, childDir);

View File

@ -34,7 +34,14 @@ function initializeStorage() {
function mkDirByPathSync(targetDir, { isRelativeToScript = false } = {}) {
const { sep } = path;
const initDir = path.isAbsolute(targetDir) ? sep : '';
const baseDir = isRelativeToScript ? __dirname : '.';
let baseDir;
if (isRelativeToScript) {
// retropilot-server/dist/worker/../.. => retropilot-server
baseDir = path.join(__dirname, '..', '..');
} else {
baseDir = '.';
}
return targetDir.split(sep)
.reduce((parentDir, childDir) => {