Grunt - 在另一个Grunt任务期间运行Grunt任务

时间:2015-04-02 23:51:08

标签: gruntjs

我试图在循环中运行另一个grunt任务,这是另一个任务的一部分。目前,以下代码完成了" publishComponents"任务然后运行" artifactory"任务。我这样做的原因是,我有一个需要发布的组件列表,我不必用不同的名称重复相同的发布任务,而是从文件中读取。任何想法将不胜感激!

    grunt.registerTask('publishComponents', 'do some stuff.', function() {
    var componentList = grunt.file.readJSON('./componentList.json');
    for (var i = 0; i < componentList.components.length; i++) {
        componentName = componentList.components[i]["name"];
        //Set File Location in Task
        fileLocation = "**/"+ componentName + "/**";
        grunt.config.set('artifactory.component.files.0.src.0', fileLocation);

        //Set Publish Name for Artifactory
        publishName = 'component:' + componentName + '-component:zip';
        grunt.config.set('artifactory.component.options.publish.0.id', publishName);

        //Set Build Name for Artifactory
        buildName = 'build.name=' + componentName + '-1.0';
        grunt.config.set('artifactory.component.options.parameters.0', buildName);
        grunt.task.run('artifactory:component:publish');
    }
});

0 个答案:

没有答案