@u4/adbkit
Version:
A Typescript client for the Android Debug Bridge.
39 lines (38 loc) • 1.49 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createClient = createClient;
const client_1 = __importDefault(require("./adb/client"));
/**
* 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();
* ```
*/
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_1.default(opts);
}
//# sourceMappingURL=adb.js.map