microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/services/validationService/checks/gradle.ts
54lines · 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 | |
| 4 | import * as nls from "vscode-nls"; |
| 5 | import { |
| 6 | basicCheck, |
| 7 | createNotFoundMessage, |
| 8 | createVersionErrorMessage, |
| 9 | parseVersion, |
| 10 | } from "../util"; |
| 11 | import { ValidationCategoryE, IValidation, ValidationResultT } from "./types"; |
| 12 | |
| 13 | nls.config({ |
| 14 | messageFormat: nls.MessageFormat.bundle, |
| 15 | bundleFormat: nls.BundleFormat.standalone, |
| 16 | })(); |
| 17 | |
| 18 | const toLocale = nls.loadMessageBundle(); |
| 19 | |
| 20 | const label = "Gradle"; |
| 21 | |
| 22 | async function test(): Promise<ValidationResultT> { |
| 23 | const result = await basicCheck({ |
| 24 | command: "gradle", |
| 25 | getVersion: parseVersion.bind(null, "gradle -version", /gradle (.*?)( |$)/gim), |
| 26 | }); |
| 27 | |
| 28 | if (!result.exists) { |
| 29 | return { |
| 30 | status: "failure", |
| 31 | comment: createNotFoundMessage(label), |
| 32 | }; |
| 33 | } |
| 34 | |
| 35 | if (result.versionCompare === undefined) { |
| 36 | return { |
| 37 | status: "failure", |
| 38 | comment: createVersionErrorMessage(label), |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | return { |
| 43 | status: "success", |
| 44 | }; |
| 45 | } |
| 46 | |
| 47 | const main: IValidation = { |
| 48 | label, |
| 49 | description: toLocale("GradleTestDescription", "Requried for building android apps"), |
| 50 | category: ValidationCategoryE.Android, |
| 51 | exec: test, |
| 52 | }; |
| 53 | |
| 54 | export default main; |
| 55 | |