diff options
Diffstat (limited to 'shared/extra-utils/miscs')
-rw-r--r-- | shared/extra-utils/miscs/miscs.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts index fb6430e4f..42250886c 100644 --- a/shared/extra-utils/miscs/miscs.ts +++ b/shared/extra-utils/miscs/miscs.ts | |||
@@ -8,7 +8,7 @@ import { pathExists, readFile } from 'fs-extra' | |||
8 | import * as ffmpeg from 'fluent-ffmpeg' | 8 | import * as ffmpeg from 'fluent-ffmpeg' |
9 | 9 | ||
10 | const expect = chai.expect | 10 | const expect = chai.expect |
11 | let webtorrent = new WebTorrent() | 11 | let webtorrent: WebTorrent.Instance |
12 | 12 | ||
13 | function immutableAssign <T, U> (target: T, source: U) { | 13 | function immutableAssign <T, U> (target: T, source: U) { |
14 | return Object.assign<{}, T, U>({}, target, source) | 14 | return Object.assign<{}, T, U>({}, target, source) |
@@ -27,6 +27,9 @@ function wait (milliseconds: number) { | |||
27 | } | 27 | } |
28 | 28 | ||
29 | function webtorrentAdd (torrent: string, refreshWebTorrent = false) { | 29 | function webtorrentAdd (torrent: string, refreshWebTorrent = false) { |
30 | const WebTorrent = require('webtorrent') | ||
31 | |||
32 | if (!webtorrent) webtorrent = new WebTorrent() | ||
30 | if (refreshWebTorrent === true) webtorrent = new WebTorrent() | 33 | if (refreshWebTorrent === true) webtorrent = new WebTorrent() |
31 | 34 | ||
32 | return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res)) | 35 | return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res)) |