From fe9b6b5041846638181abe417bc499f6b466f416 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Sun, 6 May 2018 15:39:52 +0200 Subject: [PATCH] Move toPromise to its own file --- src/manager.ts | 1 + src/sshFileSystem.ts | 7 +------ src/toPromise.ts | 7 +++++++ 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 src/toPromise.ts diff --git a/src/manager.ts b/src/manager.ts index bff5b7e..6b3ffcc 100644 --- a/src/manager.ts +++ b/src/manager.ts @@ -2,6 +2,7 @@ import { Client, ConnectConfig } from 'ssh2'; import * as vscode from 'vscode'; import SSHFileSystem, { EMPTY_FILE_SYSTEM } from './sshFileSystem'; +import { toPromise } from './toPromise'; async function assertFs(man: Manager, uri: vscode.Uri) { const fs = await man.getFs(uri); diff --git a/src/sshFileSystem.ts b/src/sshFileSystem.ts index c819098..c41e46c 100644 --- a/src/sshFileSystem.ts +++ b/src/sshFileSystem.ts @@ -4,12 +4,7 @@ import * as ssh2 from 'ssh2'; import * as ssh2s from 'ssh2-streams'; import * as vscode from 'vscode'; -type toPromiseCallback = (err: Error | null, res?: T) => void; -async function toPromise(func: (cb: toPromiseCallback) => void): Promise { - return new Promise((resolve, reject) => { - func((err, res) => err ? reject(err) : resolve(res)); - }); -} +import { toPromise } from './toPromise'; export class SSHFileSystem implements vscode.FileSystemProvider { public copy = undefined; diff --git a/src/toPromise.ts b/src/toPromise.ts new file mode 100644 index 0000000..e24bf40 --- /dev/null +++ b/src/toPromise.ts @@ -0,0 +1,7 @@ + +export type toPromiseCallback = (err: Error | null, res?: T) => void; +export async function toPromise(func: (cb: toPromiseCallback) => void): Promise { + return new Promise((resolve, reject) => { + func((err, res) => err ? reject(err) : resolve(res)); + }); +}