Print a message if Maven not installed
This commit is contained in:
@ -8,10 +8,39 @@ import { buildJars } from "./buildJars";
|
|||||||
import type { CliCommandOptions } from "../main";
|
import type { CliCommandOptions } from "../main";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
||||||
|
import * as os from "os";
|
||||||
|
|
||||||
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
|
check_if_maven_is_installed: {
|
||||||
|
let commandOutput: Buffer | undefined = undefined;
|
||||||
|
|
||||||
|
try {
|
||||||
|
commandOutput = child_process.execSync("mvn --version");
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
if (!commandOutput?.toString("utf8").includes("Apache Maven")) {
|
||||||
|
break check_if_maven_is_installed;
|
||||||
|
}
|
||||||
|
|
||||||
|
const installationCommand = (() => {
|
||||||
|
switch (os.platform()) {
|
||||||
|
case "darwin":
|
||||||
|
return "brew install nvm";
|
||||||
|
case "win32":
|
||||||
|
return "choco install nvm";
|
||||||
|
case "linux":
|
||||||
|
default:
|
||||||
|
return "sudo apt-get install nvm";
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
console.log(`${chalk.red("Apache Maven required.")} Install it with \`${chalk.bold(installationCommand)}\` (for example)`);
|
||||||
|
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({ cliCommandOptions });
|
const buildOptions = readBuildOptions({ cliCommandOptions });
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
|
Reference in New Issue
Block a user