From 793d709fb22bb195371fd52fa0a8d50a39e4accf Mon Sep 17 00:00:00 2001 From: Lucas Motta Date: Wed, 28 Nov 2018 16:16:54 +0000 Subject: [PATCH 1/3] Include missing type for the method readFile --- types/ssh2-streams/index.d.ts | 24 ++++++++++++++++++++++++ types/ssh2/index.d.ts | 20 ++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/types/ssh2-streams/index.d.ts b/types/ssh2-streams/index.d.ts index a780273591..3eaca56f6f 100644 --- a/types/ssh2-streams/index.d.ts +++ b/types/ssh2-streams/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for ssh2-streams v0.1.9 // Project: https://github.com/mscdex/ssh2-streams // Definitions by: Ron Buckton +// Definitions by: Ron Buckton // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -1044,6 +1045,24 @@ export class SFTPStream extends stream.Transform { */ fastPut(localPath: string, remotePath: string, callback: (err: any) => void): void; + /** + * (Client-only) + * Reads a file in memory and returns its contents + */ + readFile(remotePath: string, options: ReadFileOptions, callback: (err: any, handle: Buffer) => void): void; + + /** + * (Client-only) + * Reads a file in memory and returns its contents + */ + readFile(remotePath: string, encoding: string, callback: (err: any, handle: Buffer) => void): void; + + /** + * (Client-only) + * Reads a file in memory and returns its contents + */ + readFile(remotePath: string, callback: (err: any, handle: Buffer) => void): void; + /** * (Client-only) * Returns a new readable stream for `path`. @@ -1612,6 +1631,11 @@ export interface TransferOptions { step?: (total_transferred: number, chunk: number, total: number) => void; } +export interface ReadFileOptions { + encoding?: string + flag?: string +} + export interface ReadStreamOptions { flags?: string; encoding?: string; diff --git a/types/ssh2/index.d.ts b/types/ssh2/index.d.ts index 25bcfef52e..cf88fff5f1 100644 --- a/types/ssh2/index.d.ts +++ b/types/ssh2/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Qubo // Ron Buckton // Will Boyce +// Lucas Motta // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -21,6 +22,7 @@ import { Attributes, Stats, TransferOptions, + ReadFileOptions, ReadStreamOptions, WriteStreamOptions, FileEntry @@ -1273,6 +1275,24 @@ export interface SFTPWrapper extends events.EventEmitter { */ fastPut(localPath: string, remotePath: string, callback: (err: any) => void): void; + /** + * (Client-only) + * Reads a file in memory and returns its contents + */ + readFile(remotePath: string, options: ReadFileOptions, callback: (err: any, handle: Buffer) => void): void; + + /** + * (Client-only) + * Reads a file in memory and returns its contents + */ + readFile(remotePath: string, encoding: string, callback: (err: any, handle: Buffer) => void): void; + + /** + * (Client-only) + * Reads a file in memory and returns its contents + */ + readFile(remotePath: string, callback: (err: any, handle: Buffer) => void): void; + /** * (Client-only) * Returns a new readable stream for `path`. From b2133e941c8646b7a5c0581453123054314c2602 Mon Sep 17 00:00:00 2001 From: Lucas Motta Date: Wed, 28 Nov 2018 16:26:08 +0000 Subject: [PATCH 2/3] Fix credit name --- types/ssh2-streams/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ssh2-streams/index.d.ts b/types/ssh2-streams/index.d.ts index 3eaca56f6f..e80e529ced 100644 --- a/types/ssh2-streams/index.d.ts +++ b/types/ssh2-streams/index.d.ts @@ -1,7 +1,7 @@ // Type definitions for ssh2-streams v0.1.9 // Project: https://github.com/mscdex/ssh2-streams // Definitions by: Ron Buckton -// Definitions by: Ron Buckton +// Definitions by: Lucas Motta // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 3c744b74bec078faa9a9227ea23c00ffdc0a132a Mon Sep 17 00:00:00 2001 From: Lucas Motta Date: Thu, 29 Nov 2018 10:32:40 +0000 Subject: [PATCH 3/3] Fix ci problems --- types/ssh2-streams/index.d.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/types/ssh2-streams/index.d.ts b/types/ssh2-streams/index.d.ts index e80e529ced..df1e001e0a 100644 --- a/types/ssh2-streams/index.d.ts +++ b/types/ssh2-streams/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for ssh2-streams v0.1.9 // Project: https://github.com/mscdex/ssh2-streams // Definitions by: Ron Buckton -// Definitions by: Lucas Motta // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -1631,11 +1630,6 @@ export interface TransferOptions { step?: (total_transferred: number, chunk: number, total: number) => void; } -export interface ReadFileOptions { - encoding?: string - flag?: string -} - export interface ReadStreamOptions { flags?: string; encoding?: string; @@ -1704,4 +1698,9 @@ export interface ParsedKey { publicOrig: Buffer; ppk?: boolean; privateMAC?: string; +} + +export interface ReadFileOptions { + encoding?: string; + flag?: string; } \ No newline at end of file