code cleanup

This commit is contained in:
karl.hudgell 2020-04-27 11:52:09 +01:00
parent 198183d008
commit 4ce21de180
3 changed files with 30 additions and 880 deletions

797
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@
"node_modules/figlet/fonts/Standard.flf" "node_modules/figlet/fonts/Standard.flf"
], ],
"targets": [ "targets": [
"node12-linux-x86", "node12-linux-x64",
"node12-macos-x64", "node12-macos-x64",
"node12-win-x86" "node12-win-x86"
] ]

View File

@ -115,60 +115,31 @@ module.exports = {
console.log('Trying to connect with stored ipAddress') console.log('Trying to connect with stored ipAddress')
if (process.platform === 'win32' || process.platform === 'win64') { if (process.platform === 'win32' || process.platform === 'win64') {
shellExec('adb connect ' + miwatchData.ipAddress).then(async function (result) { shellExec('adb connect ' + miwatchData.ipAddress).then(async function (result) {
if (result.stdout.includes('unable to connect')) { if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
files.writeIpAddress('')
await common.pause(1000)
module.exports.connectWifi()
} else if (result.stdout.includes('cannot connect')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
files.writeIpAddress('')
await common.pause(1000)
module.exports.connectWifi()
} else if (result.stdout.includes('cannot resolve host')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
files.writeIpAddress('')
await common.pause(1000)
module.exports.connectWifi()
} else {
console.log(chalk.green('MiWatch Connected')) console.log(chalk.green('MiWatch Connected'))
await common.pause(3000) await common.pause(3000)
module.exports.mainMenu() module.exports.mainMenu()
} else {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} }
}).catch() }).catch()
} else { } else {
shellExec('./adb connect ' + miwatchData.ipAddress).then(async function (result) { shellExec('./adb connect ' + miwatchData.ipAddress).then(async function (result) {
if (result.stdout.includes('unable to connect')) { if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
files.writeIpAddress('')
await common.pause(1000)
module.exports.connectWifi()
} else if (result.stdout.includes('cannot connect')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
files.writeIpAddress('')
await common.pause(1000)
module.exports.connectWifi()
} else if (result.stdout.includes('cannot resolve host')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
files.writeIpAddress('')
await common.pause(1000)
module.exports.connectWifi()
} else {
console.log(chalk.green('MiWatch Connected')) console.log(chalk.green('MiWatch Connected'))
files.writeIpAddress(miWatchIpaddress)
await common.pause(3000) await common.pause(3000)
module.exports.mainMenu() module.exports.mainMenu()
} else {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} }
}).catch() }).catch()
} }
@ -177,56 +148,32 @@ module.exports = {
const miWatchIpaddress = value.connectWifi const miWatchIpaddress = value.connectWifi
if (process.platform === 'win32' || process.platform === 'win64') { if (process.platform === 'win32' || process.platform === 'win64') {
shellExec('adb connect ' + miWatchIpaddress).then(async function (result) { shellExec('adb connect ' + miWatchIpaddress).then(async function (result) {
if (result.stdout.includes('unable to connect')) { if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} else if (result.stdout.includes('cannot connect')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} else if (result.stdout.includes('cannot resolve host')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} else {
console.log(chalk.green('MiWatch Connected')) console.log(chalk.green('MiWatch Connected'))
files.writeIpAddress(miWatchIpaddress) files.writeIpAddress(miWatchIpaddress)
await common.pause(3000) await common.pause(3000)
module.exports.mainMenu() module.exports.mainMenu()
} else {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} }
}).catch() }).catch()
} else { } else {
shellExec('./adb connect ' + miWatchIpaddress).then(async function (result) { shellExec('./adb connect ' + miWatchIpaddress).then(async function (result) {
if (result.stdout.includes('unable to connect')) { if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} else if (result.stdout.includes('cannot connect')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} else if (result.stdout.includes('cannot resolve host')) {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} else {
console.log(chalk.green('MiWatch Connected')) console.log(chalk.green('MiWatch Connected'))
files.writeIpAddress(miWatchIpaddress) files.writeIpAddress(miWatchIpaddress)
await common.pause(3000) await common.pause(3000)
module.exports.mainMenu() module.exports.mainMenu()
} else {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
} }
}).catch() }).catch()
} }