pear-install 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +15 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,6 +24,7 @@ function ERR_EXISTS(msg, info = null) {
|
|
|
24
24
|
return new PearError(msg, ERR_EXISTS, info)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const down = isWindows ? '↓' : '⬇'
|
|
27
28
|
const PEAR_DIR = isMac
|
|
28
29
|
? path.join(os.homedir(), 'Library', 'Application Support', 'pear')
|
|
29
30
|
: isLinux
|
|
@@ -35,16 +36,12 @@ class Install extends Opstream {
|
|
|
35
36
|
installing: ({ link }) => `Installing... ${link}`,
|
|
36
37
|
app: ({ app, version, upgrade, dest, key }) =>
|
|
37
38
|
`App: ${app}\nVersion: ${version}\nLink: ${upgrade}\nPathname: ${key}\nTarget: ${dest}`,
|
|
38
|
-
stats({
|
|
39
|
+
stats({ download, peers }) {
|
|
39
40
|
const dl =
|
|
40
41
|
download.bytes + download.speed === 0
|
|
41
42
|
? ''
|
|
42
|
-
: `[ down ${byteSize(download.bytes)} - ${byteSize(download.speed)}/s ] `
|
|
43
|
-
|
|
44
|
-
upload.bytes + upload.speed === 0
|
|
45
|
-
? ''
|
|
46
|
-
: `[ up ${byteSize(upload.bytes)} - ${byteSize(upload.speed)}/s ] `
|
|
47
|
-
return `[ Peers: ${peers} ] ${dl}${ul}`
|
|
43
|
+
: ` [ ${down} ${byteSize(download.bytes)} - ${byteSize(download.speed)}/s ] `
|
|
44
|
+
return `[ Peers: ${peers} ]${dl}`
|
|
48
45
|
},
|
|
49
46
|
error: ({ message }) => message,
|
|
50
47
|
final({ success, message }) {
|
|
@@ -257,17 +254,23 @@ class Install extends Opstream {
|
|
|
257
254
|
}
|
|
258
255
|
|
|
259
256
|
static async output(json, stream) {
|
|
257
|
+
let status = false
|
|
260
258
|
for await (const { tag, data } of stream) {
|
|
261
259
|
if (json) {
|
|
262
260
|
process.stdout.write(JSON.stringify({ cmd: 'install', tag, data }) + '\n')
|
|
263
261
|
continue
|
|
264
262
|
}
|
|
265
|
-
if (tag
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
process.stdout.write('\r\x1B[2K' +
|
|
263
|
+
if (!this.outputs[tag]) continue
|
|
264
|
+
const line = this.outputs[tag](data)
|
|
265
|
+
const clear = status ? '\r\x1B[2K' : ''
|
|
266
|
+
if (tag === 'stats') {
|
|
267
|
+
process.stdout.write('\r\x1B[2K' + line)
|
|
268
|
+
status = true
|
|
269
|
+
continue
|
|
270
270
|
}
|
|
271
|
+
process.stdout.write(clear + line + '\n')
|
|
272
|
+
status = false
|
|
273
|
+
if (tag === 'final') return data
|
|
271
274
|
}
|
|
272
275
|
}
|
|
273
276
|
|