microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
fix-ts-error1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/macos/defaultsHelper.ts

34lines · modeblame

1c2424f4RedMickey5 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import { Node } from "../../common/node/node";
5import { ChildProcess } from "../../common/node/childProcess";
6
7export class DefaultsHelper {
8private readonly DEV_MENU_SETTINGS = "RCTDevMenu";
9
10private nodeChildProcess: ChildProcess;
11
12constructor() {
13this.nodeChildProcess = new Node.ChildProcess();
14}
15
0d77292aJiglioNero4 years ago16public async setPlistBooleanProperty(
1c2424f4RedMickey5 years ago17plistFile: string,
18property: string,
19value: boolean,
20): Promise<void> {
21// Attempt to set the value, and if it fails due to the key not existing attempt to create the key
0d77292aJiglioNero4 years ago22await this.invokeDefaultsCommand(
09f6024fHeniker4 years ago23`write ${plistFile} ${this.DEV_MENU_SETTINGS} -dict-add ${property} -bool ${String(
24value,
25)}`,
0d77292aJiglioNero4 years ago26);
1c2424f4RedMickey5 years ago27}
28
0d77292aJiglioNero4 years ago29private async invokeDefaultsCommand(command: string): Promise<string> {
30const res = await this.nodeChildProcess.exec(`defaults ${command}`);
31const outcome = await res.outcome;
32return outcome.toString().trim();
1c2424f4RedMickey5 years ago33}
34}