【问题标题】:Running a task from my custom task?从我的自定义任务运行任务?
【发布时间】:2016-04-11 10:49:10
【问题描述】:

我正在创建一个自定义的 grunt 任务:

grunt.registerTask('my-task', 'Do something', function() {

我希望在这个任务中运行一个 grunts 复制任务,每次都经过不同的目的地。

如何从自定义任务中运行任务,每次都传递不同的变量?

【问题讨论】:

标签: javascript gruntjs grunt-contrib-copy


【解决方案1】:

如果您正在编写自定义任务,则可以利用 grunt 公开的 API。您可以使用 grunt.task.run();

在自定义任务中运行任务
function myCustomTask(grunt) {
  grunt.log.ok('This is my custom task.');
  grunt.task.run('copy');
}

grunt.registerTask('my-task', 'Do something', myCustomTask);

您可以通过阅读此API Documentation 了解有关在自定义任务中运行任务的更多信息

【讨论】:

    猜你喜欢
    • 2019-06-07
    • 2015-12-30
    • 1970-01-01
    • 2014-02-13
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多