gpt4 book ai didi

javascript - 运行 Grunt 任务之前的确认

转载 作者:行者123 更新时间:2023-11-30 12:28:35 25 4
gpt4 key购买 nike

我在 Gruntfile.js 中有一个任务可能会删除我的项目,我想用“你确定要运行这个任务吗?”来保护它。在运行它之前先问一下,为了安全起见。像这样的东西:

grunt.registerTask('install', 'Run this only once when starting a project!', function() {
console.log('Are you sure? Y/n:');

// If yes, continue with task
grunt.task.run('copy_install');
});

但我不知道如何让它等待键盘输入并读取输入。也找不到这个记录。

最佳答案

别这样!你会后悔的!

Grunt 是一个构建工具,您的 grunt 脚本应该只能删除它创建的内容。不管你当前状态背后的原因是什么,改变它。将该工具用于其本来的用途,而不是用于删除您不想丢失的东西。

关于javascript - 运行 Grunt 任务之前的确认,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28495849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com