From 848bbb27c47f04229b51ecc3246dcd93a590f1c6 Mon Sep 17 00:00:00 2001 From: hufeng Date: Mon, 6 Feb 2023 20:20:36 +0800 Subject: [PATCH] Adapt to ohos-typescript's oh-modules package manager type Signed-off-by: hufeng Change-Id: Ib0de4f5ba8fd7db52585a364d1ada74f2d479520 --- ts2panda/src/cmdOptions.ts | 8 ++++++++ ts2panda/src/index.ts | 3 +++ 2 files changed, 11 insertions(+) diff --git a/ts2panda/src/cmdOptions.ts b/ts2panda/src/cmdOptions.ts index 0c7169dd9b8..ff02ad83b28 100644 --- a/ts2panda/src/cmdOptions.ts +++ b/ts2panda/src/cmdOptions.ts @@ -56,6 +56,7 @@ export const ts2pandaOptions = [ { name: 'output-proto', type: Boolean, defaultValue: false, description: "Output protoBin file. Default: false" }, { name: 'merge-abc', type: Boolean, defaultValue: false, description: "Compile as merge abc" }, { name: 'input-file', type: String, defaultValue: "", description: "A file containing a list of source files to be compiled. Each line of this file should be constructed in such format: fileName;recordName;moduleType;sourceFile;packageName" }, + { name: 'oh-modules', type: Boolean, defaultValue: false, description: "Set oh-modules as typescript compiler's package manager type. Default: false" } ] @@ -368,6 +369,13 @@ export class CmdOptions { return this.options["merge-abc"] } + static isOhModules(): boolean { + if (!this.options) { + return false; + } + return this.options["oh-modules"] + } + // @ts-ignore static parseUserCmd(args: string[]): ts.ParsedCommandLine | undefined { this.options = commandLineArgs(ts2pandaOptions, { partial: true }); diff --git a/ts2panda/src/index.ts b/ts2panda/src/index.ts index 23f5a202a98..65d1334a557 100644 --- a/ts2panda/src/index.ts +++ b/ts2panda/src/index.ts @@ -532,6 +532,9 @@ function run(args: string[], options?: ts.CompilerOptions): void { parsed.options = options; } } + if (CmdOptions.isOhModules()) { + parsed.options["packageManagerType"] = "ohpm"; + } try { if (CmdOptions.isWatchEvaluateDeamonMode()) { launchWatchEvaluateDeamon(parsed); -- Gitee