Skip to content

Commit

Permalink
✨ perfect qrcode function
Browse files Browse the repository at this point in the history
  • Loading branch information
轩帅 authored and 轩帅 committed Sep 22, 2022
1 parent 77feb92 commit 4bae22d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ program
const protocol = params.https ? `https` : 'http'
portfinder.basePort = 8080
portfinder.getPortPromise().then(port => {
console.log(`---`, port)
exec(`npx http-server --port ${port} ${params.https ? '--ssl' : ''}`, error => {
if (error) return print(`error`, `✘ Opps, Something Error: ${error}`)
})
Expand Down
5 changes: 1 addition & 4 deletions helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const fs = require('fs')
const os = require('os')
const path = require('path')
const chalk = require('chalk')
const qrcode = require('qrcode')

const clear = require('./clear')
const print = require('./print')
Expand Down Expand Up @@ -120,9 +119,7 @@ const showServerAdress = (port, protocol) => {
const hostname = chalk.magenta(`${protocol}://${os.hostname}:${port}`)
const ipAdress = chalk.magenta(`${protocol}://${getIp()}:${port}`)
const localAdress = chalk.magenta(`${protocol}://127.0.0.1:${port}`)
qrcode.toString(`${protocol}://${getIp()}:${port}`, { type: 'terminal' }, (err, url) => {
console.log(url)
})
generateQrcode(`${protocol}://${getIp()}:${port}`)
console.log(`\nListening on:\n✓ ${hostname} \n✓ ${ipAdress} \n✓ ${localAdress}`)
}

Expand Down
4 changes: 2 additions & 2 deletions helper/qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const saveQrcode2Loval = (string, commands) => {
}

module.exports = (string, commands) => {
qrcode.toString(string, { type: 'terminal' }, function(err, url) {
qrcode.toString(string, { type: 'terminal', small: true, width: 200}, (err, url) => {
if (err) return print('error', `✘ ${err}`)
console.log(url)
})
if (commands.save) saveQrcode2Loval(string, commands)
if (commands && commands.save) saveQrcode2Loval(string, commands)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arya-jarvis",
"version": "1.12.0",
"version": "1.12.1",
"description": "Arya Jarvis: Designed to save developers more time and energy.",
"main": "bin/index.js",
"bin": {
Expand Down

0 comments on commit 4bae22d

Please sign in to comment.