UNPKG

@u4/adbkit

Version:

A Typescript client for the Android Debug Bridge.

48 lines 1.68 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = __importDefault(require("../../command")); class UninstallError extends Error { constructor(message) { super(message); } } class UninstallCommand extends command_1.default { async execute(pkg, opts) { let cmd = 'shell:pm uninstall'; if (opts) { if (opts.keep) cmd += ' -k'; if (opts.user) cmd += ` --user ${opts.user}`; if (opts.versionCode) cmd += ` --versionCode ${opts.versionCode}`; } cmd += ` ${pkg}`; this.sendCommand(cmd); await this.readOKAY(); try { const match = await this.parser.searchLine(/^(Success|Failure.*|.*Unknown package:.*)$/); if (match[1] === 'Success') { return true; } else if (match[1].includes('DELETE_FAILED_DEVICE_POLICY_MANAGER')) { // @see https://github.com/DeviceFarmer/adbkit/pull/513 const reason = match[1]; throw new UninstallError(`${pkg} could not be uninstalled [${reason}]`); } else { // Either way, the package was uninstalled or doesn't exist, // which is good enough for us. return true; } } finally { this.parser.readAll(); } } } exports.default = UninstallCommand; //# sourceMappingURL=uninstall.js.map