From 8dcd586d48c15280707e04585b70a9ad832a8eb3 Mon Sep 17 00:00:00 2001 From: JiangKecheng <494371860@qq.com> Date: Thu, 5 Dec 2024 20:07:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(codegen-harmony):=20=E4=BF=AE=E5=A4=8Dcodeg?= =?UTF-8?q?en=E4=B8=AD=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题说明】 codegen命令中的no-safety-check和debug参数没有进行类型转换,在执行codegen-harmony指令时,debug、no-safety-check参数会按照字符串,而不是布尔类型去解析。 当输入的参数为false时,会以字符串的形式去解析,判断结构会变为true。 【修复方案】 1、参数options中增加parse转换为布尔类型,确保类型安全。 2、no-safety-check在解析成args后是“safetyCheck”,而非“noSafetyCheck”,因此在赋值给enableSafetyCheck时需要增加取反操作。 Signed-off-by: JiangKecheng <494371860@qq.com> --- react-native-harmony-cli/src/commands/codegen-harmony.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/react-native-harmony-cli/src/commands/codegen-harmony.ts b/react-native-harmony-cli/src/commands/codegen-harmony.ts index d1fe63b1..e971eb4d 100644 --- a/react-native-harmony-cli/src/commands/codegen-harmony.ts +++ b/react-native-harmony-cli/src/commands/codegen-harmony.ts @@ -50,12 +50,14 @@ export const commandCodegenHarmony: Command = { { name: '--debug [boolean]', description: 'Enables logging details', + parse: (val: string) => val !== 'false', default: false, }, { name: '--no-safety-check [boolean]', description: 'Skips the check that prevents file operations outside the current working directory. This command permanently deletes previously generated files. Files are generated in the path specified by cpp-output-path.', + parse: (val: string) => val !== 'false', }, ], func: async (_argv, _config, args: any) => { @@ -67,7 +69,7 @@ export const commandCodegenHarmony: Command = { const etsOutputPath = new AbsolutePath( args.rnohModulePath ).copyWithNewSegment('generated'); - const enableSafetyCheck: boolean = args.safetyCheck; + const enableSafetyCheck: boolean = !args.safetyCheck; const cppOutputPath = new AbsolutePath(args.cppOutputPath); const projectRootPath = new AbsolutePath(args.projectRootPath); const uberSchemaFromArkTSLibraries = await UberSchema.fromProject( -- Gitee