bimba-cli 0.4.3 → 0.4.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/package.json +1 -1
  2. package/serve.js +9 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bimba-cli",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/HeapVoid/bimba.git"
package/serve.js CHANGED
@@ -184,10 +184,9 @@ export function serve(entrypoint, flags) {
184
184
  const sockets = new Set()
185
185
  let importMapTag = null
186
186
 
187
- let _lastLines = 0
188
187
  let _fadeTimers = []
189
188
  let _fadeId = 0
190
- let _cursorOnLine = false
189
+ let _statusSaved = false
191
190
 
192
191
  function cancelFade() {
193
192
  _fadeTimers.forEach(t => clearTimeout(t))
@@ -196,22 +195,18 @@ export function serve(entrypoint, flags) {
196
195
 
197
196
  function printStatus(file, state, errors) {
198
197
  cancelFade()
199
- if (_cursorOnLine) {
200
- process.stdout.write('\x1b[1G\x1b[J')
201
- _lastLines = 0
202
- _cursorOnLine = false
203
- } else if (_lastLines > 0) {
204
- process.stdout.write(`\x1b[${_lastLines}A\x1b[J`)
205
- _lastLines = 0
198
+ if (_statusSaved) {
199
+ process.stdout.write('\x1b[u\x1b[J')
200
+ _statusSaved = false
206
201
  }
207
202
  const now = new Date().toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit', second: '2-digit' })
208
203
  const status = state === 'ok' ? theme.success(' ok ') : theme.failure(' fail ')
204
+ process.stdout.write('\x1b[s')
205
+ _statusSaved = true
209
206
  if (errors?.length) {
210
207
  process.stdout.write(` ${theme.folder(now)} ${theme.filename(file)} ${status}\n`)
211
- _lastLines = 1
212
208
  for (const err of errors) {
213
209
  printerr(err)
214
- _lastLines += 5
215
210
  }
216
211
  } else {
217
212
  const myId = ++_fadeId
@@ -221,16 +216,13 @@ export function serve(entrypoint, flags) {
221
216
  const charDelay = 22
222
217
 
223
218
  process.stdout.write(` ${theme.folder(now)} ${theme.filename(file)} ${status}`)
224
- _lastLines = 1
225
- _cursorOnLine = true
226
219
 
227
220
  for (let i = 1; i <= totalLen; i++) {
228
221
  _fadeTimers.push(setTimeout(() => {
229
- if (_fadeId !== myId || _lastLines !== 1) return
230
- process.stdout.write('\x1b[1D\x1b[K')
222
+ if (_fadeId !== myId) return
223
+ process.stdout.write('\x1b[1D \x1b[1D')
231
224
  if (i === totalLen) {
232
- _lastLines = 0
233
- _cursorOnLine = false
225
+ _statusSaved = false
234
226
  }
235
227
  }, startDelay + i * charDelay))
236
228
  }