提交 c8472084 编写于 作者: B Benjamin Pasero

allow to run unit tests from vscode again (workaround for #48205)

上级 ef241b03
......@@ -18,7 +18,7 @@ import * as arrays from 'vs/base/common/arrays';
import { TPromise } from 'vs/base/common/winjs.base';
import * as objects from 'vs/base/common/objects';
import * as extfs from 'vs/base/node/extfs';
import { nfcall, ThrottledDelayer } from 'vs/base/common/async';
import { nfcall, ThrottledDelayer, asWinJsPromise } from 'vs/base/common/async';
import uri from 'vs/base/common/uri';
import * as nls from 'vs/nls';
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
......@@ -43,7 +43,6 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { onUnexpectedError } from 'vs/base/common/errors';
import product from 'vs/platform/node/product';
import { shell } from 'electron';
import { IEncodingOverride, ResourceEncodings } from 'vs/workbench/services/files/electron-browser/encoding';
import { createReadableOfSnapshot } from 'vs/workbench/services/files/electron-browser/streams';
......@@ -906,22 +905,25 @@ export class FileService implements IFileService {
public del(resource: uri, useTrash?: boolean): TPromise<void> {
if (useTrash) {
return this.doMoveItemToTrash(resource);
return asWinJsPromise(() => this.doMoveItemToTrash(resource));
}
return this.doDelete(resource);
}
private doMoveItemToTrash(resource: uri): TPromise<void> {
private doMoveItemToTrash(resource: uri): Promise<void> {
const absolutePath = resource.fsPath;
const result = shell.moveItemToTrash(absolutePath);
if (!result) {
return TPromise.wrapError<void>(new Error(isWindows ? nls.localize('binFailed', "Failed to move '{0}' to the recycle bin", paths.basename(absolutePath)) : nls.localize('trashFailed', "Failed to move '{0}' to the trash", paths.basename(absolutePath))));
}
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.DELETE));
return (import('electron')).then(electron => { // workaround for https://github.com/Microsoft/vscode/issues/48205
const result = electron.shell.moveItemToTrash(absolutePath);
if (!result) {
return TPromise.wrapError<void>(new Error(isWindows ? nls.localize('binFailed', "Failed to move '{0}' to the recycle bin", paths.basename(absolutePath)) : nls.localize('trashFailed', "Failed to move '{0}' to the trash", paths.basename(absolutePath))));
}
return TPromise.as(null);
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.DELETE));
return TPromise.wrap(null);
});
}
private doDelete(resource: uri): TPromise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册