Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2014-10-10 09:34:01 +0400
committerFeross Aboukhadijeh <feross@feross.org>2014-10-10 09:34:01 +0400
commit99bf8c8466db12c5e88072b389eb690a47488988 (patch)
treeab71309e122fb52b6dbe23999748c6f61d2de0c5 /bin
parent80d2f86e8bebc1e660124980f55e97e5427a91d6 (diff)
fix --list option (#95)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cmd.js25
1 files changed, 11 insertions, 14 deletions
diff --git a/bin/cmd.js b/bin/cmd.js
index 4f9d348..795f5a3 100755
--- a/bin/cmd.js
+++ b/bin/cmd.js
@@ -140,9 +140,8 @@ function getRuntime () {
}
var client = new WebTorrent({
- list: argv.list,
blocklist: argv.blocklist,
- port: argv.port
+ port: !argv.list && argv.port
})
.on('error', errorAndExit)
@@ -175,8 +174,8 @@ torrent.on('infoHash', function () {
}
})
-client.on('torrent', function (torrent) {
- if (client.listening) onTorrent(torrent)
+torrent.on('ready', function () {
+ if (client.listening || argv.list) onTorrent(torrent)
else client.on('listening', onTorrent)
})
@@ -187,8 +186,15 @@ function onTorrent (torrent) {
swarm = torrent.swarm
wires = torrent.swarm.wires
+ if (argv.list) {
+ torrent.files.forEach(function (file, i) {
+ clivas.line('{3+bold:' + i + '} : {magenta:' + file.name + '}')
+ })
+ process.exit(0)
+ }
+
torrent.on('verifying', function (data) {
- if (argv.quiet || argv.list) return
+ if (argv.quiet) return
clivas.clear()
clivas.line(
'{green:verifying existing torrent} {bold:'+Math.floor(data.percentDone)+'%} ' +
@@ -197,8 +203,6 @@ function onTorrent (torrent) {
})
torrent.on('done', function () {
- if (argv.list) return
-
if (!argv.quiet) {
// TODO: expose this data from bittorrent-swarm
var numActiveWires = torrent.swarm.wires.reduce(function (num, wire) {
@@ -220,13 +224,6 @@ function onTorrent (torrent) {
}
})
- if (argv.list) {
- torrent.files.forEach(function (file, i) {
- clivas.line('{3+bold:' + i + '} : {magenta:' + file.name + '}')
- })
- process.exit(0)
- }
-
var href
if (client.server) {
href = 'http://' + networkAddress() + ':' + client.server.address().port + '/'