added quit
This commit is contained in:
parent
3c31e4838c
commit
69df1e27f4
@ -13,6 +13,7 @@ module.exports = {
|
|||||||
"Remove Xiaomi Apps",
|
"Remove Xiaomi Apps",
|
||||||
"Restore Xiaomi Apps",
|
"Restore Xiaomi Apps",
|
||||||
"Install Compatible Apps",
|
"Install Compatible Apps",
|
||||||
|
"Quit"
|
||||||
],
|
],
|
||||||
filter: function (val) {
|
filter: function (val) {
|
||||||
return val.toLowerCase();
|
return val.toLowerCase();
|
||||||
|
@ -3,6 +3,7 @@ const common = require('../lib/common');
|
|||||||
const inquirer = require('../lib/inquirer');
|
const inquirer = require('../lib/inquirer');
|
||||||
const shellExec = require('shell-exec')
|
const shellExec = require('shell-exec')
|
||||||
const files = require('../lib/files')
|
const files = require('../lib/files')
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
removeApps: async () => {
|
removeApps: async () => {
|
||||||
@ -30,29 +31,40 @@ module.exports = {
|
|||||||
module.exports.mainMenu()
|
module.exports.mainMenu()
|
||||||
},
|
},
|
||||||
connectWifi: async () => {
|
connectWifi: async () => {
|
||||||
|
const miwatchData = JSON.parse(fs.readFileSync('./data/MiWatch.json', 'utf8'));
|
||||||
common.header('Connect Wifi')
|
common.header('Connect Wifi')
|
||||||
const value = await inquirer.connectWifi();
|
if (miwatchData.ipAddress !== "") {
|
||||||
const miWatchIpaddress = value.connectWifi
|
console.log('pooooooo')
|
||||||
shellExec('adb connect ' + miWatchIpaddress).then(async function (result) {
|
} else {
|
||||||
if (result.stdout.includes('unable to connect')) {
|
const value = await inquirer.connectWifi();
|
||||||
console.log(chalk.red('MiWatch not found'))
|
const miWatchIpaddress = value.connectWifi
|
||||||
await common.pause(2000)
|
shellExec('adb connect ' + miWatchIpaddress).then(async function (result) {
|
||||||
console.log(chalk.white('Try Again'))
|
if (result.stdout.includes('unable to connect')) {
|
||||||
await common.pause(1000)
|
console.log(chalk.red('MiWatch not found'))
|
||||||
module.exports.connectWifi()
|
await common.pause(2000)
|
||||||
} else if (result.stdout.includes('cannot connect')) {
|
console.log(chalk.white('Try Again'))
|
||||||
console.log(chalk.red('MiWatch not found'))
|
await common.pause(1000)
|
||||||
await common.pause(2000)
|
module.exports.connectWifi()
|
||||||
console.log(chalk.white('Try Again'))
|
} else if (result.stdout.includes('cannot connect')) {
|
||||||
await common.pause(1000)
|
console.log(chalk.red('MiWatch not found'))
|
||||||
module.exports.connectWifi()
|
await common.pause(2000)
|
||||||
} else {
|
console.log(chalk.white('Try Again'))
|
||||||
console.log(chalk.green('MiWatch Connected'))
|
await common.pause(1000)
|
||||||
files.writeIpAddress(miWatchIpaddress)
|
module.exports.connectWifi()
|
||||||
await common.pause(3000)
|
} else if (result.stdout.includes('cannot resolve host')) {
|
||||||
module.exports.mainMenu()
|
console.log(chalk.red('MiWatch not found'))
|
||||||
}
|
await common.pause(2000)
|
||||||
}).catch()
|
console.log(chalk.white('Try Again'))
|
||||||
|
await common.pause(1000)
|
||||||
|
module.exports.connectWifi()
|
||||||
|
} else {
|
||||||
|
console.log(chalk.green('MiWatch Connected'))
|
||||||
|
files.writeIpAddress(miWatchIpaddress)
|
||||||
|
await common.pause(3000)
|
||||||
|
module.exports.mainMenu()
|
||||||
|
}
|
||||||
|
}).catch()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mainMenu: async () => {
|
mainMenu: async () => {
|
||||||
common.header('Main Menu')
|
common.header('Main Menu')
|
||||||
@ -67,6 +79,8 @@ module.exports = {
|
|||||||
case 'restore xiaomi apps':
|
case 'restore xiaomi apps':
|
||||||
module.exports.restoreApps()
|
module.exports.restoreApps()
|
||||||
break;
|
break;
|
||||||
|
case 'quit':
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// code block
|
// code block
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user