我想在运行特定任务时使用Grunt记录警告黄色消息。
目前我使用grunt.log.subhead
输出粗体字体,但不需要太多关注。
grunt.log.subhead 'You may want to use --sourceMaps option'
答案 0 :(得分:34)
你可以试试这个:
grunt.log.writeln('You may want to use --sourceMaps option'['yellow'].bold);
日志的grunt API文档没有提到如何执行此操作。我在这里的一组幻灯片中找到了它: http://slides.com/joshschumacher/grunt-logging#/
答案 1 :(得分:17)
从@jon提到的幻灯片中,有效颜色为:
var colors = ['white', 'black', 'grey', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow', 'rainbow'];
colors.forEach(function (color) {
grunt.log.writeln('testing'[color]);
grunt.log.writeln('testing bold'[color].bold);
});