diff --git a/apps/generator-cli/src/README.md b/apps/generator-cli/src/README.md index f30bf7b6f..a04f67e88 100644 --- a/apps/generator-cli/src/README.md +++ b/apps/generator-cli/src/README.md @@ -245,3 +245,4 @@ yarn add @openapitools/openapi-generator-cli@1.0.18-4.3.1 Please leave a star. + diff --git a/apps/generator-cli/src/app/helpers/index.ts b/apps/generator-cli/src/app/helpers/index.ts index ec8c11f00..61a566979 100644 --- a/apps/generator-cli/src/app/helpers/index.ts +++ b/apps/generator-cli/src/app/helpers/index.ts @@ -1,3 +1,5 @@ +import path from 'path'; + const isWin = () => process.platform === 'win32'; /** @@ -6,6 +8,6 @@ const isWin = () => process.platform === 'win32'; */ export const javaCmd: string = process.env['JAVA_HOME'] ? isWin() - ? `"${process.env['JAVA_HOME']}/bin/java"` - : `${process.env['JAVA_HOME']}/bin/java` + ? `"${path.join(process.env['JAVA_HOME'], 'bin', 'java')}"` + : `${path.join(process.env['JAVA_HOME'], 'bin', 'java')}` : 'java'; diff --git a/apps/generator-cli/src/app/services/generator.service.ts b/apps/generator-cli/src/app/services/generator.service.ts index 327f1d4de..6ae510323 100644 --- a/apps/generator-cli/src/app/services/generator.service.ts +++ b/apps/generator-cli/src/app/services/generator.service.ts @@ -243,9 +243,17 @@ export class GeneratorService { )}" org.openapitools.codegen.OpenAPIGenerator` : `-jar "${cliPath}"`; - return [javaCmd, process.env['JAVA_OPTS'], subCmd, 'generate', appendix] + const command = [ + javaCmd, + process.env['JAVA_OPTS'], + subCmd, + 'generate', + appendix, + ] .filter(isString) .join(' '); + + return this.isWin() ? `"${command}"` : command; }; private isWin = () => process.platform === 'win32';