2014-04-03 27 views
0

如果我正在创建自定义的grunt任务,它是否可以遍历其他任务的目标?说我有这在我的initConfig:注册一个自定义grunt任务时,是否可以遍历另一个任务的目标?

clean: { 
     target1: { 
      // etc etc 
     }, 
     target1: { 
      // etc etc 
     } 
    } 

,我注册一个任务:

grunt.registerTask('deploy', function() { 
    var run = []; 

    // Loop through the targets in 'clean', comparing them 
    // with details passed in in my arguments array... 

    grunt.task.run(run); 
}); 

我基本上是想查询的任务目标,并动态地构建我的东西阵列运行。

感谢,

托比

回答

1

有几个选项: http://gruntjs.com/api/grunt.config

grunt.config

获取或设置从项目的咕噜配置的值。此方法 可用作其他方法的别名;如果传递了两个参数,则调用 grunt.config.set,否则调用grunt.config.get。

grunt.config([prop [, value]]) 

grunt.config.get

获取从项目的咕噜配置的值。如果指定prop为 ,则返回该属性的值;如果未定义该属性 ,则返回null。如果没有指定prop,则返回整个config 对象的副本。模板字符串将使用grunt.config.process方法递归处理 。

grunt.config.get([prop]) 
+0

太好了,非常感谢! – toby1kenobi

相关问题