我正在尝试使用Grunt来获取桌面通知,并且已经安装了Grunt notify。按照说明,我还安装了“ Growl”(我在Windows 7上),并且还在grunt.loadNpmTasks('grunt-notify');
Gruntfile中包括了该行,但是根本没有显示桌面通知。
我想念什么吗?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']);
};
嗯...我从没用过grunt-notify插件,但是正如医生所说,该插件显示警告或任务错误。因此,如果任务成功运行,则不会通知您。如果您也不想自定义成功消息,则必须添加可选消息。
为确保问题不是安装错误导致的,请尝试运行简单的gruntfile,如插件页面上所示。如果可行,您应该考虑我的第一个解释,并在成功时添加一条自定义消息。
[编辑:尝试使用属性运行任务以-v
进行冗长的运行。如文档中所指定,如果插件有错误,它将写入日志]
这是grunt-notify示例文件(来自插件的文档):
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');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句