Skip to content

Commit

Permalink
fix: update condition for already initialized error
Browse files Browse the repository at this point in the history
  • Loading branch information
rtpascual committed Sep 13, 2023
1 parent d7a7696 commit 842bf00
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/amplify-cli/src/init-steps/s0-analyzeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,16 @@ export const analyzeProject = async (context: $TSContext): Promise<$TSContext> =
}
const projectPath = process.cwd();
context.exeInfo.isNewProject = isNewProject(context);
context.exeInfo.forcePush = !!context?.parameters?.options?.forcePush;
const projectName = await getProjectName(context);

if (context.exeInfo.isNewProject && context.parameters.command !== 'env') {
await displayAndSetDefaults(context, projectPath, projectName);
}

if (!context.exeInfo.isNewProject && context.parameters.options && context.parameters.options.yes) {
// If forcePush is true, that means running `init -y --forcePush` which is used for the init handler
// this allows the function category to run pre-push checks after project is initialized
if (!context.exeInfo.isNewProject && context.parameters.options && context.parameters.options.yes && !context.exeInfo.forcePush) {
throw new AmplifyError('ProjectInitError', {
message: `Amplify project ${stateManager.getAppID()} is already initialized for environment ${stateManager.getCurrentEnvName(
projectPath,
Expand Down

0 comments on commit 842bf00

Please sign in to comment.