我正在构建一个grunt模块,以帮助我初始化、创建默认文件夹/文件并构建一些WebProjects。我创建了一个自定义Grunt模块,包括一些自定义任务。
所以我的模块是oshell.grunt,在这个模块中,我有一个任务InitializeLibrary。此InitializeLibrary是一个自定义任务,它在创建文件/文件夹结构之前请求用户输入一些内容。我用grunt-prompt来做这个。
我的问题是当我在我的主项目中运行自定义模块时,找不到任务prompt。请您分享一下您在这方面的经验,因为我想有些开发人员也面临着同样的问题。
自定义模块结构
在主项目中安装自定义模块之后
似乎没什么问题。
InitializeLibrary.js
module.exports = function(
grunt
){
"use strict";
grunt.initConfig({
"prompt": {
"libraryInfo": {
options: {
questions: [
{
config: "InitializeOpenShellLibrary.version",
type: "input",
message: "Initial version of the library",
default: "0.1.0"
}
]
}
}
}
});
require("load-grunt-subtasks")(grunt);
grunt.registerTask(
"InitializeLibrary",
[
"prompt:libraryInfo"
]
);
}主web项目grunt文件
module.exports = function(
grunt
){
"use strict";
grunt.loadNpmTasks("oshell.grunt");
grunt.registerTask("default", ["InitializeLibrary"]);
};当我在我的主要项目中运行这个grunt时,我得到了这个结果。
Warning: Task "prompt:libraryInfo" not found. Use --force to continue.
我期望任务prompt在自定义模块中运行,以获得库信息的提示。
非常感谢你们的回答,伙计们。
发布于 2019-10-07 13:55:07
请安装https://www.npmjs.com/package/grunt-prompt并在grunt文件中添加以下代码:
grunt.loadNpmTasks('grunt-prompt');https://stackoverflow.com/questions/57441430
复制相似问题