From 9b474844e85cce916370693cc24f53339a695570 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Jul 2019 10:37:35 +0200 Subject: Add CLI plugins tests --- server/helpers/core-utils.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'server/helpers/core-utils.ts') diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index 38b6f63f8..9ff67c43a 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts @@ -4,7 +4,7 @@ */ import { createHash, HexBase64Latin1Encoding, pseudoRandomBytes } from 'crypto' -import { isAbsolute, join } from 'path' +import { basename, isAbsolute, join, resolve } from 'path' import * as pem from 'pem' import { URL } from 'url' import { truncate } from 'lodash' @@ -136,16 +136,16 @@ function getAppNumber () { return process.env.NODE_APP_INSTANCE } +let rootPath: string function root () { + if (rootPath) return rootPath + // We are in /helpers/utils.js - const paths = [ __dirname, '..', '..' ] + rootPath = join(__dirname, '..', '..') - // We are under /dist directory - if (process.mainModule && process.mainModule.filename.endsWith('_mocha') === false) { - paths.push('..') - } + if (basename(rootPath) === 'dist') rootPath = resolve(rootPath, '..') - return join.apply(null, paths) + return rootPath } // Thanks: https://stackoverflow.com/a/12034334 -- cgit v1.2.3