mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
💄 remove usage of Promise in favor TPromise
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
import 'vs/css!./actionbar';
|
||||
import nls = require('vs/nls');
|
||||
import lifecycle = require('vs/base/common/lifecycle');
|
||||
import { Promise } from 'vs/base/common/winjs.base';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Builder, $ } from 'vs/base/browser/builder';
|
||||
import { SelectBox } from 'vs/base/browser/ui/selectBox/selectBox';
|
||||
import { IAction, IActionRunner, Action, IActionChangeEvent, ActionRunner } from 'vs/base/common/actions';
|
||||
@@ -690,7 +690,7 @@ export class ActionBar extends EventEmitter implements IActionRunner {
|
||||
this.emit(CommonEventType.CANCEL);
|
||||
}
|
||||
|
||||
public run(action: IAction, context?: any): Promise {
|
||||
public run(action: IAction, context?: any): TPromise<void> {
|
||||
return this._actionRunner.run(action, context);
|
||||
}
|
||||
|
||||
@@ -765,4 +765,4 @@ export class SelectActionItem extends BaseActionItem {
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { Promise, TPromise } from 'vs/base/common/winjs.base';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as extfs from 'vs/base/node/extfs';
|
||||
import { dirname, join } from 'path';
|
||||
import { nfcall, Queue } from 'vs/base/common/async';
|
||||
@@ -19,7 +19,7 @@ export function readdir(path: string): TPromise<string[]> {
|
||||
}
|
||||
|
||||
export function exists(path: string): TPromise<boolean> {
|
||||
return new Promise(c => fs.exists(path, c));
|
||||
return new TPromise(c => fs.exists(path, c));
|
||||
}
|
||||
|
||||
export function chmod(path: string, mode: number): TPromise<boolean> {
|
||||
@@ -33,7 +33,7 @@ export function mkdirp(path: string, mode?: number): TPromise<boolean> {
|
||||
return nfcall(fs.stat, path)
|
||||
.then((stat: fs.Stats) => stat.isDirectory
|
||||
? null
|
||||
: Promise.wrapError(new Error(`'${path}' exists and is not a directory.`)));
|
||||
: TPromise.wrapError(new Error(`'${path}' exists and is not a directory.`)));
|
||||
}
|
||||
|
||||
return TPromise.wrapError<boolean>(err);
|
||||
@@ -83,15 +83,15 @@ export function lstat(path: string): TPromise<fs.Stats> {
|
||||
return nfcall(fs.lstat, path);
|
||||
}
|
||||
|
||||
export function rename(oldPath: string, newPath: string): Promise {
|
||||
export function rename(oldPath: string, newPath: string): TPromise<void> {
|
||||
return nfcall(fs.rename, oldPath, newPath);
|
||||
}
|
||||
|
||||
export function rmdir(path: string): Promise {
|
||||
export function rmdir(path: string): TPromise<void> {
|
||||
return nfcall(fs.rmdir, path);
|
||||
}
|
||||
|
||||
export function unlink(path: string): Promise {
|
||||
export function unlink(path: string): TPromise<void> {
|
||||
return nfcall(fs.unlink, path);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import spawn = cp.spawn;
|
||||
import { PassThrough } from 'stream';
|
||||
import { fork } from 'vs/base/node/stdFork';
|
||||
import nls = require('vs/nls');
|
||||
import { PPromise, Promise, TPromise, TValueCallback, TProgressCallback, ErrorCallback } from 'vs/base/common/winjs.base';
|
||||
import { PPromise, TPromise, TValueCallback, TProgressCallback, ErrorCallback } from 'vs/base/common/winjs.base';
|
||||
import * as Types from 'vs/base/common/types';
|
||||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
import URI from 'vs/base/common/uri';
|
||||
@@ -168,7 +168,7 @@ export abstract class AbstractProcess<TProgressData> {
|
||||
|
||||
public start(): PPromise<SuccessData, TProgressData> {
|
||||
if (Platform.isWindows && ((this.options && this.options.cwd && TPath.isUNC(this.options.cwd)) || !this.options && !this.options.cwd && TPath.isUNC(process.cwd()))) {
|
||||
return Promise.wrapError(new Error(nls.localize('TaskRunner.UNC', 'Can\'t execute a shell command on an UNC drive.')));
|
||||
return TPromise.wrapError(new Error(nls.localize('TaskRunner.UNC', 'Can\'t execute a shell command on an UNC drive.')));
|
||||
}
|
||||
return this.useExec().then((useExec) => {
|
||||
let cc: TValueCallback<SuccessData>;
|
||||
@@ -485,4 +485,4 @@ export function createQueuedSender(childProcess: ChildProcess | NodeJS.Process):
|
||||
};
|
||||
|
||||
return { send };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { createWriteStream } from 'fs';
|
||||
import { Readable } from 'stream';
|
||||
import { nfcall, ninvoke, SimpleThrottler } from 'vs/base/common/async';
|
||||
import { mkdirp, rimraf } from 'vs/base/node/pfs';
|
||||
import { Promise, TPromise } from 'vs/base/common/winjs.base';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { open as openZip, Entry, ZipFile } from 'yauzl';
|
||||
|
||||
export interface IExtractOptions {
|
||||
@@ -34,12 +34,12 @@ function modeFromEntry(entry: Entry) {
|
||||
.reduce((a, b) => a + b, attr & 61440 /* S_IFMT */);
|
||||
}
|
||||
|
||||
function extractEntry(stream: Readable, fileName: string, mode: number, targetPath: string, options: IOptions): Promise {
|
||||
function extractEntry(stream: Readable, fileName: string, mode: number, targetPath: string, options: IOptions): TPromise<void> {
|
||||
const dirName = path.dirname(fileName);
|
||||
const targetDirName = path.join(targetPath, dirName);
|
||||
const targetFileName = path.join(targetPath, fileName);
|
||||
|
||||
return mkdirp(targetDirName).then(() => new Promise((c, e) => {
|
||||
return mkdirp(targetDirName).then(() => new TPromise((c, e) => {
|
||||
let istream = createWriteStream(targetFileName, { mode });
|
||||
istream.once('finish', () => c(null));
|
||||
istream.once('error', e);
|
||||
@@ -48,8 +48,8 @@ function extractEntry(stream: Readable, fileName: string, mode: number, targetPa
|
||||
}));
|
||||
}
|
||||
|
||||
function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions): Promise {
|
||||
return new Promise((c, e) => {
|
||||
function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions): TPromise<void> {
|
||||
return new TPromise((c, e) => {
|
||||
const throttler = new SimpleThrottler();
|
||||
let last = TPromise.as<any>(null);
|
||||
|
||||
@@ -77,7 +77,7 @@ function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions): Pr
|
||||
});
|
||||
}
|
||||
|
||||
export function extract(zipPath: string, targetPath: string, options: IExtractOptions = {}): Promise {
|
||||
export function extract(zipPath: string, targetPath: string, options: IExtractOptions = {}): TPromise<void> {
|
||||
const sourcePathRegex = new RegExp(options.sourcePath ? `^${options.sourcePath}` : '');
|
||||
|
||||
let promise = nfcall<ZipFile>(openZip, zipPath);
|
||||
|
||||
@@ -141,7 +141,8 @@ class UninstallAction extends Action {
|
||||
|
||||
return pfs.unlink(this.target)
|
||||
.then(null, ignore('ENOENT'))
|
||||
.then(() => this.messageService.show(Severity.Info, nls.localize('successFrom', "Shell command '{0}' successfully uninstalled from PATH.", product.applicationName)));
|
||||
.then(() => this.messageService.show(Severity.Info, nls.localize('successFrom', "Shell command '{0}' successfully uninstalled from PATH.", product.applicationName)))
|
||||
.then(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user