microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.9.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/services/validationService/checks/emulator.ts

65lines · 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 nls from "vscode-nls";
5import {
6 basicCheck,
7 createNotFoundMessage,
8 createVersionErrorMessage,
9 parseVersion,
10} from "../util";
11import { ValidationCategoryE, IValidation, ValidationResultT } from "./types";
12
13nls.config({
14 messageFormat: nls.MessageFormat.bundle,
15 bundleFormat: nls.BundleFormat.standalone,
16})();
17
18const toLocale = nls.loadMessageBundle();
19
20const label = "Android Emulator";
21
22async function test(): Promise<ValidationResultT> {
23 const result = await basicCheck({
24 command: "emulator",
25 versionRange: "30.0.0",
26 getVersion: parseVersion.bind(null, "emulator -version", /version (.*?)( |$)/gi),
27 });
28
29 if (!result.exists) {
30 return {
31 status: "failure",
32 comment: createNotFoundMessage(label),
33 };
34 }
35
36 if (result.versionCompare === undefined) {
37 return {
38 status: "failure",
39 comment: createVersionErrorMessage(label),
40 };
41 }
42
43 if (result.versionCompare === -1) {
44 return {
45 status: "partial-success",
46 comment:
47 "Detected version is older than 30.0.0. " +
48 "Please update SDK tools in case of errors",
49 };
50 }
51
52 return { status: "success" };
53}
54
55const main: IValidation = {
56 label,
57 description: toLocale(
58 "EmulatorCheckDescription",
59 "Required for working with Android emulators",
60 ),
61 category: ValidationCategoryE.Android,
62 exec: test,
63};
64
65export default main;
66