microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
9e81e40f4152f5c42f065e1b0f4a4995b93b96af

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/settingsHelper.ts

53lines · 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 * as vscode from "vscode";
5import path = require("path");
6import {ConfigurationReader} from "../common/configurationReader";
7import {Packager} from "../common/packager";
8
9export class SettingsHelper {
10
11 /**
12 * Path to the workspace settings file
13 */
14 public static get settingsJsonPath(): string {
15 return path.join(vscode.workspace.rootPath, ".vscode", "settings.json");
16 }
17
18 /**
19 * Enable javascript intellisense via typescript.
20 */
21 public static notifyUserToAddTSDKInSettingsJson(path: string): void {
22 vscode.window.showInformationMessage(`Please make sure you have \"typescript.tsdk\": \"${path}\" in .vscode/settings.json and restart VSCode afterwards.`);
23 }
24
25 /**
26 * Removes javascript intellisense via typescript.
27 */
28 public static notifyUserToRemoveTSDKFromSettingsJson(path: string): void {
29 vscode.window.showInformationMessage(`Please remove \"typescript.tsdk\": \"${path}\" from .vscode/settings.json and restart VSCode afterwards.`);
30 }
31
32 /**
33 * Get the path of the Typescript TSDK as it is in the workspace configuration
34 */
35 public static getTypeScriptTsdk(): string {
36 const workspaceConfiguration = vscode.workspace.getConfiguration();
37 if (workspaceConfiguration.has("typescript.tsdk")) {
38 return ConfigurationReader.readString(workspaceConfiguration.get("typescript.tsdk"));
39 }
40 return null;
41 }
42
43 /**
44 * We get the packager port configured by the user
45 */
46 public static getPackagerPort(): number {
47 const workspaceConfiguration = vscode.workspace.getConfiguration();
48 if (workspaceConfiguration.has("react-native.packager.port")) {
49 return ConfigurationReader.readInt(workspaceConfiguration.get("react-native.packager.port"));
50 }
51 return Packager.DEFAULT_PORT;
52 }
53}