From 37023bc7863f2a2768df937a5b42dd8cbad03b91 Mon Sep 17 00:00:00 2001 From: zhangrengao Date: Sun, 21 Aug 2022 12:31:48 +0800 Subject: [PATCH] fixed 3d3cb5b from https://gitee.com/zhangrengao1/ark_ts2abc/pulls/450 Add debug file path of es2abc&ts2abc Issue: I5N4FQ Signed-off-by: zhangrengao Change-Id: Ie2488f80ccdf8806082d0a99eb59b36946cba1fc --- ts2panda/src/cmdOptions.ts | 7 ++++++- ts2panda/src/debuginfo.ts | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ts2panda/src/cmdOptions.ts b/ts2panda/src/cmdOptions.ts index b6950ea8e5..848c5519fc 100644 --- a/ts2panda/src/cmdOptions.ts +++ b/ts2panda/src/cmdOptions.ts @@ -43,7 +43,8 @@ const ts2pandaOptions = [ { name: 'record-type', alias: 'p', type: Boolean, defaultValue: false, description: "Record type info. Default: true" }, { name: 'dts-type-record', alias: 'q', type: Boolean, defaultValue: false, description: "Record type info for .d.ts files. Default: false" }, { name: 'debug-type', alias: 'g', type: Boolean, defaultValue: false, description: "Print type-related log. Default: false" }, - { name: 'output-type', type: Boolean, defaultValue: false, description: "set output type."} + { name: 'output-type', type: Boolean, defaultValue: false, description: "set output type."}, + { name: 'source-file', type: String, defaultValue: "", description: "specify the file path info recorded in generated abc" }, ] @@ -249,6 +250,10 @@ export class CmdOptions { return this.options["debug-type"]; } + static getSourceFile(): string { + return this.options["source-file"]; + } + // @ts-ignore static parseUserCmd(args: string[]): ts.ParsedCommandLine | undefined { this.options = commandLineArgs(ts2pandaOptions, { partial: true }); diff --git a/ts2panda/src/debuginfo.ts b/ts2panda/src/debuginfo.ts index 982b92334a..29e0fbe4fb 100644 --- a/ts2panda/src/debuginfo.ts +++ b/ts2panda/src/debuginfo.ts @@ -352,7 +352,11 @@ export class DebugInfo { public static setSourceFileDebugInfo(pandaGen: PandaGen, node: ts.SourceFile | ts.FunctionLikeDeclaration) { let sourceFile = jshelpers.getSourceFileOfNode(node); - pandaGen.setSourceFileDebugInfo(sourceFile.fileName); + if (CmdOptions.getSourceFile().length > 0) { + pandaGen.setSourceFileDebugInfo(CmdOptions.getSourceFile()); + } else { + pandaGen.setSourceFileDebugInfo(sourceFile.fileName); + } if (CmdOptions.isDebugMode()) { if (ts.isSourceFile(node)) { -- Gitee