Skip to content

Commit b0e66d4

Browse files
authored
refactor: java runtime jar not compress (#197)
Signed-off-by: wss-git <wssgryx@163.com>
1 parent 4ec415f commit b0e66d4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib/fc/function.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,17 +466,19 @@ export class FcFunction extends FcDeploy<FunctionConfig> {
466466
if (codeUri) {
467467
codeAbsPath = path.resolve(baseDir, codeUri);
468468

469-
let needZipJar = false;
469+
// 如果是官方的 runtime,那么不需要压缩
470+
let notCompressJar = codeUri.endsWith('.jar') && !isCustomRuntime(this.localConfig?.runtime);
471+
// 如果是 custom runtime,并且启动命令包含 java -jar 就需要压缩
470472
if (codeUri.endsWith('.jar') && isCustomRuntime(this.localConfig?.runtime)) {
471473
const command = _.get(this.localConfig, 'customRuntimeConfig.command', []);
472474
const args = _.get(this.localConfig, 'customRuntimeConfig.args', []);
473475
const commandStr = `${_.join(command, ' ')} ${_.join(args, ' ')}`;
474-
needZipJar = !commandStr.includes('java -jar');
476+
notCompressJar = !commandStr.includes('java -jar');
475477
}
476478

477-
this.logger.debug(`needZipJar: ${needZipJar}`);
479+
this.logger.debug(`notCompressJar: ${notCompressJar}`);
478480

479-
if (codeUri.endsWith('.zip') || needZipJar || codeUri.endsWith('.war')) {
481+
if (codeUri.endsWith('.zip') || notCompressJar || codeUri.endsWith('.war')) {
480482
const zipFileSizeInBytes: number = await getFileSize(codeAbsPath);
481483
return {
482484
filePath: codeAbsPath,

0 commit comments

Comments
 (0)