diff --git a/ts2panda/src/cmdOptions.ts b/ts2panda/src/cmdOptions.ts index b6950ea8e51b147344160daad71f9e77893291c5..848c5519fc820ecc21ed3f70be974dba84a2151c 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 982b92334ac084034166091af7330d2fb5f7b812..29e0fbe4fb9aacacf6a2011d2e88b887899cb88a 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)) {