Skip to content

Commit b63ee8d

Browse files
authored
[core] Add confirmation dialog before deleting dataset (#178)
1 parent 94c0048 commit b63ee8d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/@sanity/core/src/commands/dataset/deleteDatasetCommand.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ export default {
33
group: 'dataset',
44
signature: '[datasetName]',
55
description: 'Delete a dataset within your project',
6-
action: (args, context) => {
7-
const {apiClient, output} = context
6+
action: async (args, context) => {
7+
const {apiClient, prompt, output} = context
88
const [dataset] = args.argsWithoutOptions
99
if (!dataset) {
1010
throw new Error('Dataset name must be provided')
1111
}
1212

13+
await prompt.single({
14+
type: 'input',
15+
message: 'Are you ABSOLUTELY sure you want to delete this dataset?\n Type the name of the dataset to confirm delete:',
16+
validate: input => {
17+
return input === dataset || 'Incorrect dataset name. Ctrl + C to cancel delete.'
18+
}
19+
})
20+
1321
return apiClient().datasets.delete(dataset).then(() => {
1422
output.print('Dataset deleted successfully')
1523
})

0 commit comments

Comments
 (0)