Skip to content

Commit 553ea79

Browse files
fix(cli): capacitor recognize multi-project (#4937)
* fix(cli): capacitor recognize multi-project * chore: remove comment Co-authored-by: jcesarmobile <[email protected]> * chore: make command not found bubble up Co-authored-by: jcesarmobile <[email protected]>
1 parent 0c3f112 commit 553ea79

File tree

1 file changed

+20
-1
lines changed
  • packages/@ionic/cli/src/lib/integrations/capacitor

1 file changed

+20
-1
lines changed

packages/@ionic/cli/src/lib/integrations/capacitor/index.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
InfoItem,
1414
IntegrationAddDetails,
1515
IntegrationName,
16+
IShellSpawnOptions,
1617
ProjectIntegration,
1718
ProjectPersonalizationDetails
1819
} from '../../../definitions';
@@ -190,7 +191,25 @@ export class Integration extends BaseIntegration<ProjectIntegration> {
190191

191192
debug('Getting config with Capacitor CLI: %O', args);
192193

193-
const output = await this.e.shell.cmdinfo('capacitor', args, { cwd: this.root });
194+
let output = undefined;
195+
try {
196+
output = await (async (_command: string, _args: readonly string[] = [], opts: IShellSpawnOptions = {}) => {
197+
try {
198+
const proc = await this.e.shell.createSubprocess(_command, _args, opts);
199+
const out = await proc.output();
200+
return out.split('\n').join(' ').trim();
201+
} catch (err) {
202+
throw err;
203+
}
204+
})('capacitor', args, { cwd: this.root })
205+
} catch (error) {
206+
if ((error as any).code === 'ERR_SUBPROCESS_COMMAND_NOT_FOUND') {
207+
throw new Error(`Capacitor command not found. Is the Capacitor CLI installed? (npm i -D @capacitor/cli)`);
208+
} else {
209+
throw new Error((error as any).message);
210+
}
211+
}
212+
194213

195214
if (!output) {
196215
debug('Could not get config from Capacitor CLI (probably old version)');

0 commit comments

Comments
 (0)