pear-install
Advanced tools
+15
-12
@@ -27,2 +27,3 @@ 'use strict' | ||
| const down = isWindows ? '↓' : '⬇' | ||
| const PEAR_DIR = isMac | ||
@@ -39,12 +40,8 @@ ? path.join(os.homedir(), 'Library', 'Application Support', 'pear') | ||
| `App: ${app}\nVersion: ${version}\nLink: ${upgrade}\nPathname: ${key}\nTarget: ${dest}`, | ||
| stats({ upload, download, peers }) { | ||
| stats({ download, peers }) { | ||
| const dl = | ||
| download.bytes + download.speed === 0 | ||
| ? '' | ||
| : `[ down ${byteSize(download.bytes)} - ${byteSize(download.speed)}/s ] ` | ||
| const ul = | ||
| upload.bytes + upload.speed === 0 | ||
| ? '' | ||
| : `[ up ${byteSize(upload.bytes)} - ${byteSize(upload.speed)}/s ] ` | ||
| return `[ Peers: ${peers} ] ${dl}${ul}` | ||
| : ` [ ${down} ${byteSize(download.bytes)} - ${byteSize(download.speed)}/s ] ` | ||
| return `[ Peers: ${peers} ]${dl}` | ||
| }, | ||
@@ -262,2 +259,3 @@ error: ({ message }) => message, | ||
| static async output(json, stream) { | ||
| let status = false | ||
| for await (const { tag, data } of stream) { | ||
@@ -268,8 +266,13 @@ if (json) { | ||
| } | ||
| if (tag === 'final') { | ||
| process.stdout.write('\r\x1B[2K' + this.outputs.final(data) + '\n') | ||
| return data | ||
| } else if (this.outputs[tag]) { | ||
| process.stdout.write('\r\x1B[2K' + this.outputs[tag](data) + '\n') | ||
| if (!this.outputs[tag]) continue | ||
| const line = this.outputs[tag](data) | ||
| const clear = status ? '\r\x1B[2K' : '' | ||
| if (tag === 'stats') { | ||
| process.stdout.write('\r\x1B[2K' + line) | ||
| status = true | ||
| continue | ||
| } | ||
| process.stdout.write(clear + line + '\n') | ||
| status = false | ||
| if (tag === 'final') return data | ||
| } | ||
@@ -276,0 +279,0 @@ } |
+1
-1
| { | ||
| "name": "pear-install", | ||
| "version": "1.0.3", | ||
| "version": "1.0.4", | ||
| "main": "index.js", | ||
@@ -5,0 +5,0 @@ "type": "commonjs", |
39967
0.04%654
0.46%