在initConfig之外运行grunt插件

时间:2017-11-15 15:34:09

标签: gruntjs

是否有人知道在grunt.config.set中运行的插件结果中使用grunt.initConfig设置为变量的值所需的最小模式是什么?

对grunt和javascript都不熟悉,我不知道如何使用此值来运行另一个插件, 例如,我可以在grunt.initConfig内运行一个插件来获取我想要设置的值但是我现在如何运行另一组插件?

以下是我想要运行的示例:

module.exports = function(grunt) {

  grunt.loadNpmTasks('grunt');
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-template');

  grunt.initConfig({
    shell: {
      pwd: {
        command: 'pwd'
      }
    }

  });

  grunt.registerTask('default', 'shell', function() {
    grunt.config.set('pwd');

    'template': {
      'test': {
        'options': {
          'data': {
            "name": "data",
              "description": "",
              "environment": <%=pwd%>
          }
        },
        'files': {
          'project.json': ['test.tpl']
        }
      }
    }

  });

};

但它不起作用,因为我不能像在initConfig中那样简单地在registerTask部分中​​运行插件模板。

0 个答案:

没有答案
相关问题