microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/common/extensionMessaging.ts
18lines · modeblame
0502b7a8dlebu10 years ago | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. | |
| 3 | | |
a1005420dlebu10 years ago | 4 | import {HostPlatform} from "./hostPlatform"; |
d3950d7edigeff10 years ago | 5 | import {Crypto} from "./node/crypto"; |
d40a8b0fdlebu10 years ago | 6 | |
7daed3fcArtem Egorov8 years ago | 7 | export class MessagingHelper { |
| 8 | public static getPath(projectRootPath: string): string { | |
d3950d7edigeff10 years ago | 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(); | |
7daed3fcArtem Egorov8 years ago | 13 | const normalizedRootPath = projectRootPath.toLowerCase(); |
19d78568Patricio Beltran10 years ago | 14 | const uniqueSeed = `${userID}:${normalizedRootPath}`; |
d3950d7edigeff10 years ago | 15 | const hash = new Crypto().hash(uniqueSeed); |
| 16 | return HostPlatform.getPipePath(`vscode-reactnative-${hash}`); | |
0502b7a8dlebu10 years ago | 17 | } |
76c41138digeff10 years ago | 18 | } |