@u4/adbkit
Version:
A Typescript client for the Android Debug Bridge.
29 lines • 1.05 kB
JavaScript
;
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 ClearCommand extends command_1.default {
async execute(pkg) {
this.sendCommand(`shell:pm clear ${pkg}`);
await this.readOKAY();
try {
const result = await this.parser.searchLine(/^(Success|Failed)$/);
switch (result[0]) {
case 'Success':
return true;
case 'Failed':
// Unfortunately, the command may stall at this point and we
// have to kill the connection.
throw new Error(`Package '${pkg}' could not be cleared`);
}
return false;
}
finally {
this.parser.end();
}
}
}
exports.default = ClearCommand;
//# sourceMappingURL=clear.js.map