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.
Files changed (2) hide show
  1. package/index.js +15 -12
  2. 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({ upload, download, peers }) {
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
- const ul =
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 === 'final') {
266
- process.stdout.write('\r\x1B[2K' + this.outputs.final(data) + '\n')
267
- return data
268
- } else if (this.outputs[tag]) {
269
- process.stdout.write('\r\x1B[2K' + this.outputs[tag](data) + '\n')
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-install",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "index.js",
5
5
  "type": "commonjs",
6
6
  "description": "Install Pear and Pear Applications",