mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-20 00:53:26 +02:00
Ported CLI from commander to yargs because yargs suits our large CLI better and is easier to develop with. Split commands into separate files since the file was getting annoyingly long.
This commit is contained in:
@@ -8,11 +8,3 @@ module.exports.size = function(val) {
|
||||
return [Number(match[1]), Number(match[2])]
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.range = function(from, to) {
|
||||
var items = []
|
||||
for (var i = from; i <= to; ++i) {
|
||||
items.push(i)
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
@@ -145,64 +145,7 @@ doctor.checkADB = function() {
|
||||
)
|
||||
}
|
||||
|
||||
doctor.checkDevices = function() {
|
||||
// Show all connected USB devices, including hubs
|
||||
if (os.platform() === 'darwin') {
|
||||
childProcess.execFile('ioreg', ['-p', 'IOUSB', '-w0'],
|
||||
function(error, stdout, stderr) {
|
||||
log.info('USB devices connected including hubs:')
|
||||
if (!execHasErrors(error, stderr)) {
|
||||
var list = stdout.replace(/@.*|\+-o Root\s{2}.*\n|\+-o |^\s{2}/gm, '')
|
||||
.split('\n')
|
||||
list.forEach(function(device) {
|
||||
log.info(device)
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
else if (os.platform() === 'linux') {
|
||||
childProcess.execFile('lsusb', [],
|
||||
function(error, stdout, stderr) {
|
||||
log.info('USB devices connected including hubs:')
|
||||
if (!execHasErrors(error, stderr)) {
|
||||
var list = stdout.replace(/Bus \d+ Device \d+: ID \w+:\w+ /gm, '')
|
||||
.split('\n')
|
||||
list.forEach(function(device) {
|
||||
log.info(device)
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Show all the devices seen by adb
|
||||
childProcess.execFile('adb', ['devices'],
|
||||
function(error, stdout, stderr) {
|
||||
log.info('Devices that ADB can see:')
|
||||
if (!execHasErrors(error, stderr)) {
|
||||
var s = stdout.replace(/List of devices attached \n|^\s*/gm, '')
|
||||
if (s.length === 0) {
|
||||
log.error('No devices')
|
||||
}
|
||||
else {
|
||||
var list = s.split('\n')
|
||||
list.forEach(function(device) {
|
||||
log.info(device)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
doctor.run = function(options) {
|
||||
// Check devices
|
||||
if (options.devices) {
|
||||
doctor.checkDevices()
|
||||
return
|
||||
}
|
||||
|
||||
doctor.run = function() {
|
||||
// Check OS architecture
|
||||
doctor.checkOSArch()
|
||||
|
||||
|
||||
@@ -81,10 +81,10 @@ srv.resolve = function(domain) {
|
||||
var parsedUrl = url.parse(domain)
|
||||
|
||||
if (!parsedUrl.protocol) {
|
||||
return Promise.reject(new Error(
|
||||
return Promise.reject(new Error(util.format(
|
||||
'Must include protocol in "%s"'
|
||||
, domain
|
||||
))
|
||||
)))
|
||||
}
|
||||
|
||||
if (/^srv\+/.test(parsedUrl.protocol)) {
|
||||
|
||||
Reference in New Issue
Block a user