Skip to content

Fix 2FA prompt when the package exists#505

Merged
sindresorhus merged 24 commits into
sindresorhus:masterfrom
chinesedfan:fix-exists
Apr 27, 2020
Merged

Fix 2FA prompt when the package exists#505
sindresorhus merged 24 commits into
sindresorhus:masterfrom
chinesedfan:fix-exists

Conversation

@chinesedfan

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Owner

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

Done

@chinesedfan

Copy link
Copy Markdown
Contributor 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

itaisteinherz commented Feb 27, 2020

Copy link
Copy Markdown
Collaborator

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

Comment thread source/cli.js Outdated
Comment thread source/index.js
Comment thread test/index.js Outdated
Comment thread test/index.js Outdated
@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
Comment thread source/index.js Outdated
Comment thread test/index.js Outdated
Comment thread test/index.js
test('should not enable 2fa if the package exists', async t => {
const enable2faStub = sinon.stub();
const np = proxyquire('../source', {
del: sinon.stub(),

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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