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

fix: added exit code on remove #5427

Merged
merged 5 commits into from
Sep 29, 2020

Conversation

ammarkarachi
Copy link
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov
Copy link

codecov bot commented Sep 28, 2020

Codecov Report

Merging #5427 into master will decrease coverage by 0.00%.
The diff coverage is 58.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5427      +/-   ##
==========================================
- Coverage   59.12%   59.12%   -0.01%     
==========================================
  Files         399      400       +1     
  Lines       17970    17976       +6     
  Branches     3558     3558              
==========================================
+ Hits        10625    10628       +3     
- Misses       6697     6700       +3     
  Partials      648      648              
Impacted Files Coverage Δ
.../amplify-category-auth/src/commands/auth/remove.js 75.00% <0.00%> (-5.00%) ⬇️
packages/amplify-cli-core/src/exitOnNextTick.ts 33.33% <33.33%> (ø)
...amplify-category-notifications/lib/channel-APNS.js 62.92% <50.00%> (+0.42%) ⬆️
packages/amplify-cli/src/index.ts 48.51% <66.66%> (ø)
packages/amplify-cli-core/src/index.ts 100.00% <100.00%> (ø)
packages/amplify-cli/src/commands/delete.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c630145...0aabff5. Read the comment docs.

Copy link
Member

@edwardfoyle edwardfoyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "print error message, log usage data, exit code 1" pattern seems to exist in lots of different places. Maybe it would be worthwhile to put a utility function in amplify-cli-core like exitWithError(err, friendlyMessage) that can be used in all of these places

Copy link
Member

@edwardfoyle edwardfoyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think it might be worthwhile to encompass the print error, log usage data, exit pattern within a function in cli-core. That function can use the exitOnNextTick function and will give us an easy way to make sure the cli exits properly when adding new flows in the future.

// amplify delete run method calls process.exit() in certain situations. To avoid this affecting tests when they run, spy on process.exit()
// calls and intercept them, performing a NOP, instead.
//
// https://stackoverflow.com/questions/46148169/stubbing-process-exit-with-jest
const mockExit = jest.spyOn(process, 'exit').mockImplementation(() => undefined as never);

import { UnknownArgumentError } from 'amplify-cli-core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: doesn't look like this is actually used in the test?

@ammarkarachi ammarkarachi merged commit 33132f7 into aws-amplify:master Sep 29, 2020
yuth pushed a commit to yuth/amplify-cli that referenced this pull request Oct 2, 2020
* fix: added exit code on remove

* fix: added exit code

* fix: exit on next tick

* test: fixed abort test

* test: fixed delete.test.ts
r0zar pushed a commit to r0zar/amplify-cli that referenced this pull request Nov 19, 2020
* fix: added exit code on remove

* fix: added exit code

* fix: exit on next tick

* test: fixed abort test

* test: fixed delete.test.ts
@github-actions
Copy link

This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants