microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0fc1f1ded677de3d424c138ff2b42948ec8d4f08

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/settingsHelper.ts

56lines · 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 const tsdk = workspaceConfiguration.get("typescript.tsdk");
39 if (tsdk) {
40 return ConfigurationReader.readString(tsdk);
41 }
42 }
43 return null;
44 }
45
46 /**
47 * We get the packager port configured by the user
48 */
49 public static getPackagerPort(): number {
50 const workspaceConfiguration = vscode.workspace.getConfiguration();
51 if (workspaceConfiguration.has("react-native.packager.port")) {
52 return ConfigurationReader.readInt(workspaceConfiguration.get("react-native.packager.port"));
53 }
54 return Packager.DEFAULT_PORT;
55 }
56}