Skip to content

Commit

Permalink
chore: remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryAnansky committed Jan 20, 2025
1 parent 4b4a862 commit d2df098
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/cli/src/cms/api/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
PushResponse,
UpsertRemoteResponse,
} from './types';
import type { Readable } from 'stream';

interface BaseApiClient {
request(url: string, options: FetchWithTimeoutOptions): Promise<Response>;
Expand Down Expand Up @@ -372,7 +373,7 @@ export type PushPayload = {
isMainBranch?: boolean;
};

async function streamToBuffer(stream: ReadStream): Promise<Buffer> {
export async function streamToBuffer(stream: ReadStream | Readable): Promise<Buffer> {
const chunks: Buffer[] = [];
for await (const chunk of stream) {
chunks.push(chunk);
Expand Down
9 changes: 1 addition & 8 deletions packages/cli/src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '../utils/miscellaneous';
import { promptClientToken } from './login';
import { handlePush as handleCMSPush } from '../cms/commands/push';
import { streamToBuffer } from '../cms/api/api-client';

import type { Config, BundleOutputFormat, Region } from '@redocly/openapi-core';
import type { CommandArgs } from '../wrapper';
Expand Down Expand Up @@ -463,11 +464,3 @@ async function uploadFileToS3(url: string, filePathOrBuffer: string | Buffer) {

return fetch(url, requestOptions);
}

async function streamToBuffer(stream: Readable): Promise<Buffer> {
const chunks: Buffer[] = [];
for await (const chunk of stream) {
chunks.push(chunk);
}
return Buffer.concat(chunks);
}

0 comments on commit d2df098

Please sign in to comment.