Skip to content

Commit

Permalink
feat(adb): allow rm to delete folders
Browse files Browse the repository at this point in the history
  • Loading branch information
yume-chan committed Aug 4, 2023
1 parent 9c1b5e2 commit e86e288
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions libraries/adb/src/adb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,27 @@ export class Adb implements Closeable {
return stdout.trim();
}

async rm(...filenames: string[]): Promise<string> {
async rm(
filenames: string | string[],
options?: { recursive?: boolean; force?: boolean },
): Promise<string> {
const args = ["rm"];
if (options?.recursive) {
args.push("-r");
}
if (options?.force) {
args.push("-f");
}
if (Array.isArray(filenames)) {
for (const filename of filenames) {
args.push(escapeArg(filename));
}
} else {
args.push(escapeArg(filenames));
}
// https://android.googlesource.com/platform/packages/modules/adb/+/1a0fb8846d4e6b671c8aa7f137a8c21d7b248716/client/adb_install.cpp#984
const stdout = await this.subprocess.spawnAndWaitLegacy([
"rm",
...filenames.map((arg) => escapeArg(arg)),
"</dev/null",
]);
args.push("</dev/null");
const stdout = await this.subprocess.spawnAndWaitLegacy(args);
return stdout;
}

Expand Down

1 comment on commit e86e288

@vercel
Copy link

@vercel vercel bot commented on e86e288 Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.