UNPKG

@u4/adbkit

Version:

A Typescript client for the Android Debug Bridge.

33 lines (32 loc) 1.21 kB
import Client from './adb/client.js'; /** * Creates a client instance with the provided options. Note that this will not automatically establish a connection, it will only be done when necessary. * @param options An object compatible with [Net.connect][net-connect]'s options: * **port** The port where the ADB server is listening. Defaults to `5037`. * **host** The host of the ADB server. Defaults to `'127.0.0.1'`. * **bin** As the sole exception, this option provides the path to the `adb` binary, used for starting the server locally if initial connection fails. Defaults to `'adb'`. * * @returns The client instance. * @example * Function you should import and call first * ```ts * import { createClient } fronm @u4/adbkit * * const client = createClient(); * ``` */ export function createClient(options = { port: 5037 }) { const opts = { bin: options.bin, host: options.host || process.env.ADB_HOST, port: options.port || 5037, }; if (!opts.port) { const port = parseInt(process.env.ADB_PORT || '5037', 10); if (!isNaN(port)) { opts.port = port; } } return new Client(opts); } //# sourceMappingURL=adb.js.map