Skip to content

Commit

Permalink
feat(deps): replace @inquirer/confirm with prompts (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
andriyor authored Jun 28, 2024
1 parent 9238a06 commit 7671d61
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 169 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
coverage
node_modules
.idea
6 changes: 3 additions & 3 deletions lib/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const confirm = require('@inquirer/confirm').default
const prompts = require('prompts')

const applyChanges = require('../applyChanges')
const getChanges = require('../getChanges')
Expand All @@ -11,7 +11,7 @@ const jestItUp = require('..')

jest.spyOn(process, 'cwd').mockImplementation(() => '/workingDir')

jest.mock('@inquirer/confirm')
jest.mock('prompts')

jest.mock('../applyChanges')
jest.mock('../getChanges', () =>
Expand Down Expand Up @@ -89,7 +89,7 @@ it('runs with custom margin', async () => {
it.each([true, false])(
'runs in interactive mode with %p confirmation',
async confirmed => {
confirm.mockResolvedValueOnce(confirmed)
prompts.mockResolvedValueOnce({ isConfirmed: confirmed })

await jestItUp({ interactive: true })

Expand Down
12 changes: 10 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
const path = require('path')
const confirm = require('@inquirer/confirm').default
const prompts = require('prompts')

const applyChanges = require('./applyChanges')
const getChanges = require('./getChanges')
Expand Down Expand Up @@ -41,7 +41,15 @@ module.exports = async ({
}

const confirmed =
!interactive || (await confirm({ message: 'Update thresholds?' }))
!interactive ||
(
await prompts({
type: 'confirm',
name: 'isConfirmed',
message: 'Update thresholds?',
initial: true,
})
).isConfirmed

if (!confirmed) {
return
Expand Down
Loading

0 comments on commit 7671d61

Please sign in to comment.