Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more explicit log on 'ionic cap build' error #5094

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/@ionic/cli/src/lib/integrations/capacitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export class Integration extends BaseIntegration<ProjectIntegration> {
});

getCapacitorCLIConfig = lodash.memoize(async (): Promise<CapacitorCLIConfig | undefined> => {
const command = 'capacitor'
const args = ['config', '--json'];

debug('Getting config with Capacitor CLI: %O', args);
Expand All @@ -201,10 +202,13 @@ export class Integration extends BaseIntegration<ProjectIntegration> {
} catch (err) {
throw err;
}
})('capacitor', args, { cwd: this.root })
})(command, args, { cwd: this.root })
} catch (error) {
if ((error as any).code === 'ERR_SUBPROCESS_COMMAND_NOT_FOUND') {
throw new Error(`Capacitor command not found. Is the Capacitor CLI installed? (npm i -D @capacitor/cli)`);
} else if ((error as any).output) {
const errorLog = "\n> " + ((error as any).output as string).replaceAll("\n", "\n> ");
throw new Error(`'${command} ${args.join(" ")}' failed with: ${errorLog}`);
} else {
throw new Error((error as any).message);
}
Expand Down