aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/core-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/core-utils.ts')
-rw-r--r--server/helpers/core-utils.ts23
1 files changed, 5 insertions, 18 deletions
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index 4ff07848c..443115336 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -3,23 +3,14 @@
3 Useful to avoid circular dependencies. 3 Useful to avoid circular dependencies.
4*/ 4*/
5 5
6import { join } from 'path'
7import { pseudoRandomBytes } from 'crypto'
8import {
9 readdir,
10 readFile,
11 rename,
12 unlink,
13 writeFile,
14 access,
15 stat,
16 Stats
17} from 'fs'
18import * as mkdirp from 'mkdirp'
19import * as bcrypt from 'bcrypt' 6import * as bcrypt from 'bcrypt'
20import * as createTorrent from 'create-torrent' 7import * as createTorrent from 'create-torrent'
21import * as rimraf from 'rimraf' 8import { pseudoRandomBytes } from 'crypto'
9import { readdir, readFile, rename, stat, Stats, unlink, writeFile } from 'fs'
10import * as mkdirp from 'mkdirp'
11import { join } from 'path'
22import * as pem from 'pem' 12import * as pem from 'pem'
13import * as rimraf from 'rimraf'
23 14
24function isTestInstance () { 15function isTestInstance () {
25 return process.env.NODE_ENV === 'test' 16 return process.env.NODE_ENV === 'test'
@@ -100,7 +91,6 @@ function promisify2WithVoid<T, U> (func: (arg1: T, arg2: U, cb: (err: any) => vo
100 } 91 }
101} 92}
102 93
103const readFilePromise = promisify2<string, string, string>(readFile)
104const readFileBufferPromise = promisify1<string, Buffer>(readFile) 94const readFileBufferPromise = promisify1<string, Buffer>(readFile)
105const unlinkPromise = promisify1WithVoid<string>(unlink) 95const unlinkPromise = promisify1WithVoid<string>(unlink)
106const renamePromise = promisify2WithVoid<string, string>(rename) 96const renamePromise = promisify2WithVoid<string, string>(rename)
@@ -108,7 +98,6 @@ const writeFilePromise = promisify2WithVoid<string, any>(writeFile)
108const readdirPromise = promisify1<string, string[]>(readdir) 98const readdirPromise = promisify1<string, string[]>(readdir)
109const mkdirpPromise = promisify1<string, string>(mkdirp) 99const mkdirpPromise = promisify1<string, string>(mkdirp)
110const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes) 100const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes)
111const accessPromise = promisify1WithVoid<string | Buffer>(access)
112const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey) 101const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey)
113const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey) 102const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey)
114const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare) 103const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare)
@@ -130,14 +119,12 @@ export {
130 promisify1, 119 promisify1,
131 120
132 readdirPromise, 121 readdirPromise,
133 readFilePromise,
134 readFileBufferPromise, 122 readFileBufferPromise,
135 unlinkPromise, 123 unlinkPromise,
136 renamePromise, 124 renamePromise,
137 writeFilePromise, 125 writeFilePromise,
138 mkdirpPromise, 126 mkdirpPromise,
139 pseudoRandomBytesPromise, 127 pseudoRandomBytesPromise,
140 accessPromise,
141 createPrivateKey, 128 createPrivateKey,
142 getPublicKey, 129 getPublicKey,
143 bcryptComparePromise, 130 bcryptComparePromise,