bajo 0.2.14 → 0.2.15

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/boot/lib/bora.js +9 -9
  2. package/package.json +1 -1
package/boot/lib/bora.js CHANGED
@@ -7,10 +7,10 @@ const { sprintf } = Sprintf
7
7
  class Bora {
8
8
  constructor (ns, ...args) {
9
9
  this.ns = ns
10
- const l = last(args)
11
10
  let opts = {}
12
- if (isPlainObject(l)) opts = args.pop()
11
+ if (isPlainObject(args.slice(-1)[0])) opts = args.pop()
13
12
  this.opts = opts
13
+ this.opts.isSilent = !!this.opts.isSilent
14
14
  this.ora = ora(this.opts)
15
15
  this.args = args
16
16
  this.startTime = null
@@ -21,9 +21,7 @@ class Bora {
21
21
  const { getConfig, dayjs } = this.scope.bajo.helper
22
22
  this.startTime = dayjs()
23
23
  const config = getConfig()
24
- let silent = !!config.silent
25
- if (this.opts.skipSilent) silent = false
26
- this.ora.isSilent = silent
24
+ this.ora.isSilent = !!config.silent || this.opts.isSilent
27
25
  const [text, ...params] = this.args
28
26
  this.setText(text, ...params)
29
27
  }
@@ -36,13 +34,15 @@ class Bora {
36
34
  if (isPlainObject(args[0])) text = i18n.t(text, args[0])
37
35
  else text = i18n.t(text, { ns: this.ns, postProcess: 'sprintf', sprintf: args })
38
36
  } else text = sprintf(text, ...args)
37
+ this.ora.text = text
39
38
  let opts = last(args)
40
- if (!isPlainObject(opts)) opts = {}
39
+ const prefixes = []
41
40
  const texts = []
42
- if (this.opts.showDatetime || opts.showDatetime) texts.push('[' + dayjs().toISOString() + ']')
41
+ if (!isPlainObject(opts)) opts = {}
42
+ if (this.opts.showDatetime || opts.showDatetime) prefixes.push('[' + dayjs().toISOString() + ']')
43
43
  if (this.opts.showCounter || opts.showCounter) texts.push('[' + this.getElapsed() + ']')
44
- texts.push(text)
45
- this.ora.text = texts.join(' ')
44
+ if (prefixes.length > 0) this.ora.prefixText = this.ora.prefixText + prefixes.join(' ')
45
+ if (texts.length > 0) this.ora.text = texts.join(' ') + ' ' + text
46
46
  }
47
47
  return this
48
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {