Skip to content

Commit 794efb8

Browse files
committed
Handle relative paths in Client.removeDir()
Fixes #207
1 parent 4a83b4b commit 794efb8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Client.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,13 @@ export class Client {
604604
async removeDir(remoteDirPath: string): Promise<void> {
605605
return this._exitAtCurrentDirectory(async () => {
606606
await this.cd(remoteDirPath)
607+
// Get the absolute path of the target because remoteDirPath might be a relative path, even `../` is possible.
608+
const absoluteDirPath = await this.pwd()
607609
await this.clearWorkingDir()
608-
if (remoteDirPath !== "/") {
610+
const dirIsRoot = absoluteDirPath === "/"
611+
if (!dirIsRoot) {
609612
await this.cdup()
610-
await this.removeEmptyDir(remoteDirPath)
613+
await this.removeEmptyDir(absoluteDirPath)
611614
}
612615
})
613616
}

0 commit comments

Comments
 (0)