Grunt通知未运行

时间:2015-05-08 08:58:07

标签: javascript node.js gruntjs

我正在尝试使用Grunt进行桌面通知,并已安装Grunt notify。根据说明,我还安装了“Growl”(我在Windows 7上),并在我的Gruntfile中包含了行grunt.loadNpmTasks('grunt-notify');,但桌面通知根本没有显示。

我错过了什么吗? Grunt Notify页面似乎意味着添加loadNpmTasks行是我的gruntfile中唯一需要使用默认选项的添加。

这是我的Gruntfile:

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({

    less: {
      development: {
        options: {
            paths: ["less"],
            compress: true,
            strictMath: true,
            sourceMap: false,
            sourceMapFilename: 'css/styles.css.map',
            sourceMapRootpath: '/'
        },
        files: {
            "css/styles.css": "css/style.less"
        }
      }
    },

    uglify: {
      my_target: {
        files: {
          'js/custom.min.js': ['js/custom.js']
        }
      }
    },

    watch: {
      compile: {
          files: ['**/*.php', 'css/**/*.less', 'js/**/*.js', '!js/custom.min.js'],
          tasks: ['less', 'uglify'],
          options: { 
            atBegin: true,
            livereload: true
          }
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-notify');

  // Default task(s).
  grunt.registerTask('default', ['less']);

};

1 个答案:

答案 0 :(得分:1)

嗯...我从未使用过grunt-notify插件,但正如文档所说,这个插件显示了你的任务的警告或错误。因此,如果您的任务成功运行,则不应通知您。 如果您也想成功自定义消息,则必须添加选项消息。

要确保问题不是安装错误的影响,请尝试在插件页面上运行示例中显示的简单grunt文件。 如果有效,您应该考虑我的第一个解释,并在成功时添加自定义消息。

[编辑:尝试使用属性-v运行您的任务以进行详细运行。如文档中所指定,如果插件出现错误,它将写入日志

这是grunt-notify示例文件(来自插件' doc):

grunt.initConfig({
  // This is optional!
  notify_hooks: {
    options: {
      enabled: true,
      max_jshint_notifications: 5, // maximum number of notifications from jshint output
      title: "Project Name", // defaults to the name in package.json, or will use project directory's name
      success: false, // whether successful grunt executions should be notified automatically
      duration: 3 // the duration of notification in seconds, for `notify-send only
    }
  }
});

// Load the task
grunt.loadNpmTasks('grunt-notify');

// This is required if you use any options.
grunt.task.run('notify_hooks');