spmjs / node-scp2

[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
384 stars 96 forks source link

Basic Typescript Definitions #49

Open serkanyersen opened 8 years ago

serkanyersen commented 8 years ago

it might help someone. Here are the definitions I'm using for typescript.

declare module "scp2" {

    interface ScpOptions {
        port?: number;
        host?: string;
        username?: string;
        password?: string;
        paths?: string;
    }

    interface attrs {
        size: number;
        uid: number;
        gid: number;
        mode: number | string;
        atime: number;
        mtime: number;
    }

    interface writeOptions {
        destination: string;
        content: string;
        attrs: attrs;
        source: string;
    }

    export class Client {
        constructor(options: ScpOptions);
        sftp(callback: (err: string, sftp: Client) => void);
        close(): void;
        mkdir(dir: string, attrs: attrs, callback: (err: string) => void);
        write(options: writeOptions, callback: (err: string) => void);
        upload(src: string, destination: string, callback: (err: string) => void);
        download(src: string, destination: string, callback: (err: string) => void);
        on(eventName: string, callback: () => void);
    }

    export interface client {
        defaults(options: ScpOptions);
        scp(fileName: string, options: ScpOptions | string, errCallback?: (err: string) => void);
        scp(fileName: string, options: ScpOptions | string, glob: string, errCallback?: (err: string) => void);
    }
}

And now you can use it as

import { Client } from 'scp2';

let client = new Client({
    port: 22
});
maitrungduc1410 commented 4 years ago

You just saved my day

sthuber90 commented 3 years ago

It would be so great if this would be merged