aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/core-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-19 10:37:35 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit9b474844e85cce916370693cc24f53339a695570 (patch)
tree10b1148a7581a2754e336a144c085a05ce72a1db /server/helpers/core-utils.ts
parent32fe00138990627749da58ff9f845584013aa219 (diff)
downloadPeerTube-9b474844e85cce916370693cc24f53339a695570.tar.gz
PeerTube-9b474844e85cce916370693cc24f53339a695570.tar.zst
PeerTube-9b474844e85cce916370693cc24f53339a695570.zip
Add CLI plugins tests
Diffstat (limited to 'server/helpers/core-utils.ts')
-rw-r--r--server/helpers/core-utils.ts14
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
6import { createHash, HexBase64Latin1Encoding, pseudoRandomBytes } from 'crypto' 6import { createHash, HexBase64Latin1Encoding, pseudoRandomBytes } from 'crypto'
7import { isAbsolute, join } from 'path' 7import { basename, isAbsolute, join, resolve } from 'path'
8import * as pem from 'pem' 8import * as pem from 'pem'
9import { URL } from 'url' 9import { URL } from 'url'
10import { truncate } from 'lodash' 10import { 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
139let rootPath: string
139function root () { 140function 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