microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.6.3

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/appcenter/auth/tokenStore/index.ts

40lines · 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
4import { TokenStore } from "./tokenStore";
5import { createFileTokenStore } from "./fileTokenStore";
6import * as path from "path";
7import * as fs from "fs";
8import * as os from "os";
9
10export * from "./tokenStore";
11export const tokenFile = "VSCodeAppCenterTokens.json";
12
13let store: TokenStore;
14
15const tokenDirName: string = ".vscode-react-native";
16
17function getTokenDir(): string {
18 const tokenDir = path.join(getTokenDirParent(), tokenDirName);
19 return tokenDir;
20}
21
22function getTokenDirParent(): string {
23 if (os.platform() === "win32") {
24 return process.env.AppData;
25 } else {
26 return os.homedir();
27 }
28}
29
30// Currently only support file-base token store
31const tokenFilePath = path.join(getTokenDir(), tokenFile);
32if (!fs.existsSync(tokenFilePath)) {
33 if (!fs.existsSync(getTokenDir())) {
34 fs.mkdirSync(getTokenDir());
35 }
36 fs.writeFileSync(tokenFilePath, /* create empty */ "");
37}
38store = createFileTokenStore(tokenFilePath);
39export const tokenStore = store;
40
41