Merge pull request #30892 from lucasmotta/ssh2-read-file

[ssh2|ssh2-streams] - Include missing type for the method readFile
This commit is contained in:
Andrew Casey
2018-12-04 11:24:03 -08:00
committed by GitHub
2 changed files with 43 additions and 0 deletions

View File

@@ -1044,6 +1044,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`.
@@ -1680,4 +1698,9 @@ export interface ParsedKey {
publicOrig: Buffer;
ppk?: boolean;
privateMAC?: string;
}
export interface ReadFileOptions {
encoding?: string;
flag?: string;
}

20
types/ssh2/index.d.ts vendored
View File

@@ -3,6 +3,7 @@
// Definitions by: Qubo <https://github.com/tkQubo>
// Ron Buckton <https://github.com/rbuckton>
// Will Boyce <https://github.com/wrboyce>
// Lucas Motta <https://github.com/lucasmotta>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -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`.