Skip to content

Commit f25af8a

Browse files
sairus2kAnton Savoskinkettanaito
authoredFeb 12, 2024··
feat: use a lightweight "@inquirer/confirm" in the CLI (#2020)
Co-authored-by: Anton Savoskin <sairu2k@gmail.com> Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
1 parent a957235 commit f25af8a

File tree

3 files changed

+130
-17
lines changed

3 files changed

+130
-17
lines changed
 

‎cli/init.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fs = require('fs')
22
const path = require('path')
33
const chalk = require('chalk')
44
const { until } = require('@open-draft/until')
5-
const inquirer = require('inquirer')
5+
const confirm = require('@inquirer/confirm')
66
const invariant = require('./invariant')
77
const { SERVICE_WORKER_BUILD_PATH } = require('../config/constants')
88

@@ -180,18 +180,14 @@ function saveWorkerDirectory(packageJsonPath, publicDir) {
180180
}
181181

182182
function promptWorkerDirectoryUpdate(message, packageJsonPath, publicDir) {
183-
return inquirer
184-
.prompt({
185-
type: 'confirm',
186-
name: 'saveWorkerDirectory',
183+
return confirm({
184+
theme: {
187185
prefix: chalk.yellowBright('?'),
188-
message,
189-
})
190-
.then((answers) => {
191-
if (!answers.saveWorkerDirectory) {
192-
return
193-
}
194-
186+
},
187+
message,
188+
}).then((answer) => {
189+
if (answer) {
195190
saveWorkerDirectory(packageJsonPath, publicDir)
196-
})
191+
}
192+
})
197193
}

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
"dependencies": {
115115
"@bundled-es-modules/cookie": "^2.0.0",
116116
"@bundled-es-modules/statuses": "^1.0.1",
117+
"@inquirer/confirm": "^3.0.0",
117118
"@mswjs/cookies": "^1.1.0",
118119
"@mswjs/interceptors": "^0.25.16",
119120
"@open-draft/until": "^2.1.0",
@@ -123,7 +124,6 @@
123124
"chokidar": "^3.4.2",
124125
"graphql": "^16.8.1",
125126
"headers-polyfill": "^4.0.2",
126-
"inquirer": "^8.2.0",
127127
"is-node-process": "^1.2.0",
128128
"outvariant": "^1.4.2",
129129
"path-to-regexp": "^6.2.0",

‎pnpm-lock.yaml

+120-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.