我一直在重构现有网站,以便更有效地使用gulp和npm。我想将查询者纳入我的任务中来定义一些构建备选方案。现在我开始很简单。
这是我当前的gulpfile:
//Define our required components
var gulp = require('gulp');
var inq = require('inquirer');
var plugins = require('gulp-load-plugins')({ scope: ['dependencies', 'devDependencies'] });
//Function that retrieves the file for the specifically names task
function getTask(task) {
return require('./gulp-tasks/' + task)(gulp, plugins);
};
//Call for our tasks
gulp.task('thirdPartyComponents', getTask('ThirdPartyComponents'));
gulp.task('thirdPartyComponents.css', getTask('ThirdPartyComponentsCss'));
gulp.task('buyer.app', getTask('Buyer.App'));
gulp.task('buyer.controllers', getTask('Buyer.Controllers'));
gulp.task('buyer.directives', getTask('Buyer.Directives'));
gulp.task('buyer.filters', getTask('Buyer.Filters'));
//CODE NOTE: Dependent tasks are case-sensitive
gulp.task('default', function () {
var questions =
[
{
type: 'confirm',
name: 'minimize',
message: 'Do you want to minimize the files?',
default: true
}
];
inq.prompt(questions).then(function (answers) {
console.log(answers);
});
});
当我运行任务时,我在任务浏览器的输出窗口中得到它
[16:21:21] Using gulpfile ....
[16:21:21] Starting 'default'...
[16:21:21] 'default' errored after 185 ms
[16:21:21] Error: Implement me. Unknown stdin file type!
at process.stdin (node.js:740:17)
at setupReadlineOptions (C:\Projects\BuyerSupplier\BuyerSupplier\Main\Source\BuyerSupplier.site-dev\src\BuyerSupplier.site\node_modules\inquirer\lib\ui\baseUI.js:57:35)
at module.exports (C:\Projects\BuyerSupplier\BuyerSupplier\Main\Source\BuyerSupplier.site-dev\src\BuyerSupplier.site\node_modules\inquirer\lib\ui\baseUI.js:14:40)
at new module.exports (C:\Projects\BuyerSupplier\BuyerSupplier\Main\Source\BuyerSupplier.site-dev\src\BuyerSupplier.site\node_modules\inquirer\lib\ui\prompt.js:15:8)
at Object.promptModule [as prompt] (C:\Projects\BuyerSupplier\BuyerSupplier\Main\Source\BuyerSupplier.site-dev\src\BuyerSupplier.site\node_modules\inquirer\lib\inquirer.js:26:14)
at Gulp.<anonymous> (C:\Projects\BuyerSupplier\BuyerSupplier\Main\Source\BuyerSupplier.site-dev\src\BuyerSupplier.site\Gulpfile.js:31:9)
at module.exports (C:\Projects\BuyerSupplier\BuyerSupplier\Main\Source\BuyerSupplier.site-dev\src\BuyerSupplier.site\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\Projects\BuyerSupplier\BuyerSupplier\Main\Source\BuyerSupplier.site-dev\src\BuyerSupplier.site\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\Projects\BuyerSupplier\BuyerSupplier\Main\Source\BuyerSupplier.site-dev\src\BuyerSupplier.site\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (C:\Projects\BuyerSupplier\BuyerSupplier\Main\Source\BuyerSupplier.site-dev\src\BuyerSupplier.site\node_modules\orchestrator\index.js:134:8)
Process terminated with code 1.
我不确定为什么这个直截了当的东西不想发射......任何帮助都非常感激。
答案 0 :(得分:1)
发现问题,它与代码无直接关系。我在Visual Studio中运行,并使用Task Runner Explorer调用默认任务。这是我看到这个问题的地方。
在做了更多研究之后,我突发奇想,从命令窗口运行了gulp任务。它按预期完成。因此,Task runner中的问题仍然存在使用process.stdin
命令的命令。