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 2FA prompt when the package exists #505

Merged
merged 24 commits into from
Apr 27, 2020

Conversation

chinesedfan
Copy link
Collaborator

Fixes regressions in #490.

  • Recover to skip checking package availability if publish is false.
  • Fix conditions for 2fa prompt, as no options.exists now.

Can we merge #399 first? It will be easier to write tests.

@sindresorhus
Copy link
Owner

Can we merge #399 first? It will be easier to write tests.

Done

@chinesedfan
Copy link
Collaborator Author

@sindresorhus Good. And I'd also like the other two approved pull requests (#495, #497) can be merged first.

Note that this PR includes changes of #497 now.

@itaisteinherz
Copy link
Collaborator

itaisteinherz commented Feb 27, 2020

@chinesedfan Note that I merged #497, and reviewed #495.
(Also, CI is failing for some reason.)

source/cli.js Outdated Show resolved Hide resolved
source/index.js Outdated Show resolved Hide resolved
test/index.js Outdated Show resolved Hide resolved
test/index.js Outdated Show resolved Hide resolved
@chinesedfan chinesedfan changed the title Fix 2fa prompt when the package is existed Fix 2fa prompt when the package exists Feb 27, 2020
@sindresorhus sindresorhus changed the title Fix 2fa prompt when the package exists Fix 2FA prompt when the package exists Feb 27, 2020
source/index.js Outdated Show resolved Hide resolved
test/index.js Outdated Show resolved Hide resolved
test('should not enable 2fa if the package exists', async t => {
const enable2faStub = sinon.stub();
const np = proxyquire('../source', {
del: sinon.stub(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need all of these stubs? Can't we run np with --yolo and remove the need for most of them? While I do want the tests to reflect actual stability, I think it's more important in this case to be as specific as possible, and only test what we need to verify - that we skip enabling 2FA when not needed to do so.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

--yolo can only remove del and execa. I used to want to use --preview, but it would skip the enable2fa task totally. And I don't think adding stubs will affect the correctness of the test case. Maybe because I consider it as unit test, while you treat it as end-to-end test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants