提交 307b58f2 编写于 作者: B Benjamin Pasero

extract method

上级 774b83b0
......@@ -106,11 +106,13 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
// Setup Windows mutex
let windowsMutex: Mutex = null;
try {
const Mutex = (<any>require.__$__nodeRequire('windows-mutex')).Mutex;
windowsMutex = new Mutex(product.win32MutexName);
} catch (e) {
// noop
if (platform.isWindows) {
try {
const Mutex = (<any>require.__$__nodeRequire('windows-mutex')).Mutex;
windowsMutex = new Mutex(product.win32MutexName);
} catch (e) {
// noop
}
}
// Register Main IPC services
......@@ -265,6 +267,25 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
const logService = accessor.get(ILogService);
const environmentService = accessor.get(IEnvironmentService);
function allowSetForegroundWindow(service: LaunchChannelClient): TPromise<void> {
let promise = TPromise.as(null);
if (platform.isWindows) {
promise = service.getMainProcessId()
.then(processId => {
logService.log('Sending some foreground love to the running instance:', processId);
try {
const { allowSetForegroundWindow } = <any>require.__$__nodeRequire('windows-foreground-love');
allowSetForegroundWindow(processId);
} catch (e) {
// noop
}
});
}
return promise;
}
function setup(retry: boolean): TPromise<Server> {
return serve(environmentService.mainIPCHandle).then(server => {
if (platform.isMacintosh) {
......@@ -299,21 +320,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
const channel = client.getChannel<ILaunchChannel>('launch');
const service = new LaunchChannelClient(channel);
let promise = TPromise.as(null);
if (platform.isWindows) {
promise = service.getMainProcessId()
.then(processId => {
logService.log('Sending some foreground love to the running instance:', processId);
try {
const { allowSetForegroundWindow } = <any>require.__$__nodeRequire('windows-foreground-love');
allowSetForegroundWindow(processId);
} catch (e) {
// noop
}
});
}
return promise
return allowSetForegroundWindow(service)
.then(() => service.start(environmentService.args, process.env))
.then(() => client.dispose())
.then(() => TPromise.wrapError('Sent env to running instance. Terminating...'));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册