From 0ab4881736f0d3b967d12802cb9cd01ba24d2088 Mon Sep 17 00:00:00 2001 From: Mike Summerfeldt <20338451+IT-MikeS@users.noreply.github.com> Date: Mon, 26 Sep 2022 10:59:57 -0400 Subject: [PATCH] fix(cli): capacitor config not being read from multi-project directories (#4909) * fix(cli): use exec to run cap command in right cwd * chore: fix deps causing build errors * chore: cleanup * chore: promise should reject from exec error --- .../cli/src/lib/integrations/capacitor/index.ts | 12 +++++++++++- packages/@ionic/lab/package.json | 5 +++-- packages/@ionic/v1-toolkit/package.json | 5 +++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/@ionic/cli/src/lib/integrations/capacitor/index.ts b/packages/@ionic/cli/src/lib/integrations/capacitor/index.ts index d6c22d3e82..92e4043bed 100644 --- a/packages/@ionic/cli/src/lib/integrations/capacitor/index.ts +++ b/packages/@ionic/cli/src/lib/integrations/capacitor/index.ts @@ -1,3 +1,4 @@ +import { exec, ExecOptions } from 'child_process'; import { parseArgs } from '@ionic/cli-framework'; import { mkdirp, pathExists } from '@ionic/utils-fs'; import { prettyPath } from '@ionic/utils-terminal'; @@ -190,7 +191,16 @@ export class Integration extends BaseIntegration { debug('Getting config with Capacitor CLI: %O', args); - const output = await this.e.shell.cmdinfo('capacitor', args, { cwd: this.root }); + const output = await ((cmd: string, opts: ExecOptions): Promise => { + return new Promise((resolve, reject) => { + exec(cmd, opts, (error, stdout, stderr) => { + if (error) { + reject(); + } + resolve(stdout); + }) + }) + })(`capacitor ${args.join(' ')}`, { cwd: this.root }); if (!output) { debug('Could not get config from Capacitor CLI (probably old version)'); diff --git a/packages/@ionic/lab/package.json b/packages/@ionic/lab/package.json index ca4acb5674..5462600f96 100644 --- a/packages/@ionic/lab/package.json +++ b/packages/@ionic/lab/package.json @@ -44,13 +44,14 @@ "@ionic/cli-framework": "5.1.3", "@ionic/utils-fs": "3.1.6", "chalk": "^4.0.0", - "express": "^4.16.2", + "express": "4.16.2", "tslib": "^2.0.1" }, "devDependencies": { "@ionic-internal/ionic-ds": "^2.1.0", "@stencil/core": "~1.8.5", - "@types/express": "^4.11.0", + "@types/express": "4.11.0", + "@types/express-serve-static-core": "4.11.0", "@types/node": "~10.17.13", "lint-staged": "^10.0.2", "rimraf": "^3.0.0", diff --git a/packages/@ionic/v1-toolkit/package.json b/packages/@ionic/v1-toolkit/package.json index 2087899fdf..862f0adfd2 100644 --- a/packages/@ionic/v1-toolkit/package.json +++ b/packages/@ionic/v1-toolkit/package.json @@ -42,7 +42,7 @@ "chalk": "^4.0.0", "chokidar": "^3.0.1", "debug": "^4.0.0", - "express": "^4.16.2", + "express": "4.16.2", "gulp": "^4.0.2", "http-proxy-middleware": "^0.20.0", "tiny-lr": "^1.1.0", @@ -51,7 +51,8 @@ }, "devDependencies": { "@types/debug": "^4.1.1", - "@types/express": "^4.11.0", + "@types/express": "4.11.0", + "@types/express-serve-static-core": "4.11.0", "@types/gulp": "^4.0.6", "@types/http-proxy-middleware": "^0.19.0", "@types/jest": "^26.0.10",