microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.8.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/macos/defaultsHelper.ts

32lines · 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(
1c2424f4RedMickey5 years ago23`write ${plistFile} ${this.DEV_MENU_SETTINGS} -dict-add ${property} -bool ${value}`,
0d77292aJiglioNero4 years ago24);
1c2424f4RedMickey5 years ago25}
26
0d77292aJiglioNero4 years ago27private async invokeDefaultsCommand(command: string): Promise<string> {
28const res = await this.nodeChildProcess.exec(`defaults ${command}`);
29const outcome = await res.outcome;
30return outcome.toString().trim();
1c2424f4RedMickey5 years ago31}
32}