0.1.9 • Published 4 years ago

adb-commander v0.1.9

Weekly downloads
1,645
License
-
Repository
-
Last release
4 years ago

adb-commander

tested with jest code style: prettier

provide adb(Android Debug Bridge) command functions

Examples

deviceList

const adbCommander = require('adb-commander')

adbCommander.deviceList().then((deviceList, err) => {
  if (err) {
    console.error('fail to execute adb devices')
    return
  }
  if (deviceList.length > 0) {
    console.info(`devices is ${deviceList.join(',')}`)
  }
})

install and isInstalled

const adbCommander = require('adb-commander')

adbCommander.install(apkPath)
    .then(({ result, err }) => {
        if (err) {
            console.error('install failed')
        }
        adbCommander.isInstalled(deviceSn, 'org.hapjs.debugger').then(({isInstalled, err }) => {
            if(isInstalled === true){
                console.log('org.hapjs.debugger is installed')
            }
        })

     })
)

unInstall

const adbCommander = require('adb-commander')

adbCommander.uninstall( deviceSn, 'org.hapjs.debugger')
    .then(({ result, err }) => {
        if (err) {
            console.error('uninstall failed')
        }
        adbCommander.isInstalled(deviceSn, 'org.hapjs.debugger').then(({isInstalled, err }) => {
            if(isInstalled === false){
                console.log('org.hapjs.debugger is uninstalled')
            }
        })
     })
)

startActivity

params

  • deviceSn string
  • action string optional
  • component string optional
  • extra [{key: string, type: string, value: <any>}, ...] optional
const adbCommander = require('adb-commander')

adbCommander
  .startActivity(deviceSn, action, component, extra)
  .then(({ result, err }) => {
    if (err) {
      console.error('startActivity failed')
      return
    }
    console.log('start activity result', { result, err })
  })

exeCommand 执行 adb 命令

const adbCommander = require('adb-commander')

adbCommander.exeCommand('adb devices').then(({ result, err }) => {
  if (err) {
    console.error("exeCommand 'adb devices' failed")
    return
  }
  console.log('adb devices result', { result, err })
})
0.1.9

4 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.7

5 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago