async rmdir(remoteDir, recursive = false) {
    const _rmdir = (dir) => {
      let listeners;
      return new Promise((resolve, reject) => {
        listeners = addTempListeners(this, '_rmdir', reject);
        this.sftp.rmdir(dir, (err) => {
          if (err) {
            reject(this.fmtError(`${err.message} ${dir}`, 'rmdir', err.code));
          }
          resolve('Successfully removed directory');
        });
      }).finally(() => {
        removeTempListeners(this, listeners, '_rmdir');
      });
    };

    const _delFiles = (path, fileList) => {
      let listeners;
      return new Promise((resolve, reject) => {
        listeners = addTempListeners(this, '_delFiles', reject);
        const pList = [];
        for (const f of fileList) {
          pList.push(this.delete(`${path}/${f.name}`, true, false));
        }
        resolve(pList);
      })
        .then((p) => {
          return Promise.all(p);
        })
        .finally(() => {
          removeTempListeners(this, listeners, '_delFiles');
        });
    };

    try {
      const absPath = await normalizeRemotePath(this, remoteDir);
      const existStatus = await this.exists(absPath);
      if (!existStatus) {
        throw this.fmtError(
          `Bad Path: ${remoteDir}: No such directory`,
          'rmdir',
          errorCode.badPath,
        );
      }
      if (existStatus !== 'd') {
        throw this.fmtError(
          `Bad Path: ${remoteDir}: Not a directory`,
          'rmdir',
          errorCode.badPath,
        );
      }
      if (!recursive) {
        return await _rmdir(absPath);
      }
      const listing = await this.list(absPath);
      if (!listing.length) {
        return await _rmdir(absPath);
      }
      const fileList = listing.filter((i) => i.type !== 'd');
      const dirList = listing.filter((i) => i.type === 'd');
      await _delFiles(absPath, fileList);
      for (const d of dirList) {
        await this.rmdir(`${absPath}/${d.name}`, true);
      }
      await _rmdir(absPath);
      return 'Successfully removed directory';
    } catch (err) {
      throw err.custom
        ? err
        : this.fmtError(`${err.message} ${remoteDir}`, 'rmdir', err.code);
    }
  }
@async

Remove directory on remote server

@param {string} remotePath - path to directory to be removed
@param {boolean} recursive - if true, remove directories/files in target
                            directory
@return {Promise<String>}