Skip to content

Commit

Permalink
fix: publish returns with exitcode 1 (#5413)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshbhu authored Sep 28, 2020
1 parent afbe065 commit 2064830
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/amplify-cli-core/src/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export class MissingParametersError extends Error {}
export class NonEmptyDirectoryError extends Error {}
export class InvalidEnvironmentNameError extends Error {}
export class InvalidSubCommandError extends Error {}
export class FrontendBuildError extends Error {}
15 changes: 11 additions & 4 deletions packages/amplify-cli/src/commands/publish.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { run as push } from './push';
import { FrontendBuildError } from 'amplify-cli-core';

export const run = async context => {
context.amplify.constructExeInfo(context);
Expand Down Expand Up @@ -34,9 +35,15 @@ export const run = async context => {
continueToPublish = await context.amplify.confirmPrompt('Do you still want to publish the frontend?');
}

if (continueToPublish) {
const frontendPlugins = context.amplify.getFrontendPlugins(context);
const frontendHandlerModule = require(frontendPlugins[context.exeInfo.projectConfig.frontend]);
await frontendHandlerModule.publish(context);
try {
if (continueToPublish) {
const frontendPlugins = context.amplify.getFrontendPlugins(context);
const frontendHandlerModule = require(frontendPlugins[context.exeInfo.projectConfig.frontend]);
await frontendHandlerModule.publish(context);
}
} catch (e) {
context.print.error(`An error occurred during the publish operation`);
context.usageData.emitError(new FrontendBuildError());
process.exit(1);
}
};

0 comments on commit 2064830

Please sign in to comment.