From f35674701d6b549759555a8e89135ced5bd3131a Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Sun, 7 Nov 2021 04:35:19 -0800 Subject: [PATCH] soong: Fix trailing comma for one-line modules --- src/build/soong.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/build/soong.ts b/src/build/soong.ts index d6da0da..af4cf27 100644 --- a/src/build/soong.ts +++ b/src/build/soong.ts @@ -249,8 +249,10 @@ export function serializeModule(module: SoongModule) { serialized = `${type} ${serialized}` // Add trailing comma to last prop let serialLines = serialized.split('\n') - serialLines[serialLines.length - 2] = serialLines.at(-2) + ',' - serialized = serialLines.join('\n') + if (serialLines.length > 1) { + serialLines[serialLines.length - 2] = serialLines.at(-2) + ',' + serialized = serialLines.join('\n') + } return serialized }