microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/common/extensionMessaging.ts
18lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
| 3 | |
| 4 | import {HostPlatform} from "./hostPlatform"; |
| 5 | import {Crypto} from "./node/crypto"; |
| 6 | |
| 7 | export class MessagingHelper { |
| 8 | public static getPath(projectRootPath: string): string { |
| 9 | /* We need to use a different value for each VS Code window so the pipe names won't clash. |
| 10 | We create the pipe path hashing the user id + project root path so both client and server |
| 11 | will generate the same path, yet it's unique for each vs code instance */ |
| 12 | const userID = HostPlatform.getUserID(); |
| 13 | const normalizedRootPath = projectRootPath.toLowerCase(); |
| 14 | const uniqueSeed = `${userID}:${normalizedRootPath}`; |
| 15 | const hash = new Crypto().hash(uniqueSeed); |
| 16 | return HostPlatform.getPipePath(`vscode-reactnative-${hash}`); |
| 17 | } |
| 18 | } |
| 19 | |