Skip to content

Commit

Permalink
fix(cli): cleaning shell API
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSound committed Oct 11, 2024
1 parent a94bf40 commit b29fe9f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
import readline from 'node:readline'
import { appendFileHeaderMetaToBuffer, createGeneraterANSI } from '@qifi/generate'

Check failure on line 7 in packages/cli/src/index.ts

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find module '@qifi/generate' or its corresponding type declarations.
import mime from 'mime'

Expand Down Expand Up @@ -33,14 +34,17 @@ async function generateQRCodes(filePath: string, sliceSize: number = 80, fps: nu
})

// Clear console function
const clearConsole = () => process.stdout.write('\x1Bc')
const clearConsole = () => {
readline.cursorTo(process.stdout, 0, 0)
readline.clearScreenDown(process.stdout)
}

// Display QR codes
for (const blockQRCode of generator.fountain()) {
clearConsole()
console.log(blockQRCode)
console.log(`${meta.filename} (${meta.contentType})`, '|', 'size:', data.length, 'bytes')
await new Promise(resolve => setTimeout(resolve, 1000 / fps)) // Display each QR code for 1 second
process.stdout.write(`${blockQRCode}\n`)
process.stdout.write(`${meta.filename} (${meta.contentType}) | size: ${data.length} bytes`)
await new Promise(resolve => setTimeout(resolve, 1000 / fps))
}
}

Expand Down

0 comments on commit b29fe9f

Please sign in to comment.