2017-08-27 226 views
0

我正在運行grunt命令,但它顯示我想要刪除的頁眉和頁腳。運行grunt命令時刪除輸出頁眉和頁腳

這是我Gruntfile.js

module.exports = function(grunt) { 
    grunt.initConfig({ 
     exec: { 
      ls: { 
       command: 'ls -la', 
       stdout: true, 
       stderr: true, 
      } 
     } 
    }); 
    grunt.loadNpmTasks('grunt-exec'); 
    grunt.registerTask('ls', ['exec:ls']); 
} 

,這就是我得到:

[編輯]

我得到了下面的圖像上突出顯示的標題混淆。我想強調:

Running "exec:ls" (exec) task 

enter image description here

有也許有些選項我可以使用目標中移除(黃色突出顯示)?

+0

您是否突出顯示了正確的文字?你的意思是隱藏標題:即'運行'exec:1s「(exec)task'而不是你運行的命令:即'$ grunt ls'? – RobC

+0

哦,是的,你是對的。固定。 – Angel

回答

1

Running "exec:ls" (exec) task可以通過安裝grunt-reporter

Gruntfile.js省略

Gruntfile.js可以如下進行配置:

module.exports = function (grunt) { 

    grunt.initConfig({ 
    reporter: { 
     exec: { 
     options: { 
      tasks: ['exec:ls'], 
      header: false 
     } 
     } 
    }, 

    exec: { 
     ls: { 
     command: 'ls -la', 
     stdout: true, 
     stderr: true 
     } 
    } 
    }); 

    require('load-grunt-tasks')(grunt); 

    grunt.registerTask('ls', [ 
    'reporter:exec', //<-- The call to the reporter must be before exec. 
    'exec:ls' 
    ]); 
} 

grunt-reporter使用未加載grunt.loadNpmTasks(...)。相反它利用load-grunt-task。這也將處理加載grunt-exec,所以不需要grunt.loadNpmTasks(...)任何其他模塊。


但對於Done

不幸的是grunt-reporter沒有提供省略最終的Done消息的功能。

要省略Done您必須求助於完成用空函數替換grunt的內部grunt.log.success函數。這種方法並不特別好,因爲它有點破解。例如,你可以添加以下內容到你的配置的頂部:

module.exports = function (grunt) { 

    grunt.log.success = function() {}; // <-- Add this before grunt.initConfig({...}) 

    // ... 

} 

同樣的黑客也可以用於頭,也不過是grunt-reporter IMO一個更簡潔的方法。即

module.exports = function (grunt) { 

    grunt.log.header = function() {}; // <-- Blocks all header logs. 

    // ... 

} 
+0

謝謝,那工作! – Angel