【问题标题】:How to optimise grunt configuration如何优化 grunt 配置
【发布时间】:2015-10-03 21:19:11
【问题描述】:

我正在使用grunt-vagrnat-ssh 插件设置一些grunt 任务。

我想避免在提供的示例配置中出现一些不必要的重复。更具体地说,我说的是 pathflags 甚至可能是 callback 字段。

我是否有机会为我的所有任务和 shell 命令定义一次?

基本上改如下

grunt.initConfig({
    vagrantssh: {
        addfile: {
            path: './.vvv/',
            commands: [
                'echo "testing" > /tmp/test.txt',
                'cat /tmp/test.txt'
            ],
            flags: [ '-t', '-A' ],
            callback: function( grunt, output ) {
                grunt.log.writeln( 'Output: ' + output );
            }
        },
        removefile: {
            path: './.vvv/',
            commands: [
                'rm -rf /tmp/test.txt',
                'cat /tmp/test.txt'
            ],
            flags: [ '-t', '-A' ],
            callback: function( grunt, output ) {
                grunt.log.writeln( 'Output: ' + output );
            }
        }
    }
});

类似

grunt.initConfig({
    vagrantssh: {
        options: {
            path: './.vvv/',
            flags: [ '-t', '-A' ],
            callback: function( grunt, output ) {
                grunt.log.writeln( 'Output: ' + output );
            }
        },
        addfile: {
            commands: [
                'echo "testing" > /tmp/test.txt',
                'cat /tmp/test.txt'
            ],                
        },
        removefile: {                
            commands: [
                'rm -rf /tmp/test.txt',
                'cat /tmp/test.txt'
            ],
        }
    }
});

不幸的是,上面的配置不起作用(至少对我来说),我也尝试过保持原始回调完好无损,但仍然没有运气:(

任何建议将不胜感激:)

【问题讨论】:

    标签: node.js gruntjs config


    【解决方案1】:

    some minor amendment 在插件上解决的问题。

    pull requires 已创建,正在等待 Carl 合并 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-17
      • 2010-12-28
      • 2021-10-11
      • 1970-01-01
      • 2012-04-14
      • 2013-06-20
      相关资源
      最近更新 更多