diff options
Diffstat (limited to 'server/helpers/core-utils.ts')
-rw-r--r-- | server/helpers/core-utils.ts | 14 |
1 files changed, 7 insertions, 7 deletions
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 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | import { createHash, HexBase64Latin1Encoding, pseudoRandomBytes } from 'crypto' | 6 | import { createHash, HexBase64Latin1Encoding, pseudoRandomBytes } from 'crypto' |
7 | import { isAbsolute, join } from 'path' | 7 | import { basename, isAbsolute, join, resolve } from 'path' |
8 | import * as pem from 'pem' | 8 | import * as pem from 'pem' |
9 | import { URL } from 'url' | 9 | import { URL } from 'url' |
10 | import { truncate } from 'lodash' | 10 | import { truncate } from 'lodash' |
@@ -136,16 +136,16 @@ function getAppNumber () { | |||
136 | return process.env.NODE_APP_INSTANCE | 136 | return process.env.NODE_APP_INSTANCE |
137 | } | 137 | } |
138 | 138 | ||
139 | let rootPath: string | ||
139 | function root () { | 140 | function root () { |
141 | if (rootPath) return rootPath | ||
142 | |||
140 | // We are in /helpers/utils.js | 143 | // We are in /helpers/utils.js |
141 | const paths = [ __dirname, '..', '..' ] | 144 | rootPath = join(__dirname, '..', '..') |
142 | 145 | ||
143 | // We are under /dist directory | 146 | if (basename(rootPath) === 'dist') rootPath = resolve(rootPath, '..') |
144 | if (process.mainModule && process.mainModule.filename.endsWith('_mocha') === false) { | ||
145 | paths.push('..') | ||
146 | } | ||
147 | 147 | ||
148 | return join.apply(null, paths) | 148 | return rootPath |
149 | } | 149 | } |
150 | 150 | ||
151 | // Thanks: https://stackoverflow.com/a/12034334 | 151 | // Thanks: https://stackoverflow.com/a/12034334 |