Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Commit

Permalink
0.2.8
Browse files Browse the repository at this point in the history
 * Fixed bug caused Grunt-Notify to not work in 32-bit windows.
 * Fixed bug that prevented Snarl from working if the task ended quickly from an error.
 * Removed defaults for how many notifications and how long notifications say on the screen for Snarl.
 * Replaced Nodeunit tests with Mocha tests.
  • Loading branch information
dylang committed Aug 18, 2013
1 parent 1b48bfd commit 90783c3
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 113 deletions.
50 changes: 31 additions & 19 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,58 @@

module.exports = function(grunt) {

// Project configuration.

grunt.initConfig({
cafemocha: {
notify: {
src: 'test/**/*.test.js',
options: {
timeout: 10000,
ui: 'bdd',
reporter: 'spec',
require: [
'chai'
]
}
}
},
jshint: {
all: [
'Gruntfile.js',
'tasks/**/*.js',
'<%= nodeunit.tests %>'
'tests/**/*'
],
fixtures: [
'test/fixtures/*.js'
],
options: {
jshintrc: '.jshintrc',
force: false
force: true
}
},

watch: {
test: {
files: ['**/*.js'],
tasks: ['nodeunit', 'notify'],
files: [
'Gruntfile.js',
'tasks/**/*.js',
'test/**/*.js'
],
tasks: ['cafemocha'],
options: {
nospawn: true
}
}
},

// Configuration to be run (and then tested).
notify: {
custom_options: {
options: {
title: 'Notify Title',
message: 'This is a "Notify Message" test!'
}
},
notify: {
custom_options: {
options: {
title: 'Notify Title',
message: 'This is a "Notify Message" test!'
}
},
just_message: {
options: {
message: 'Just Message'
Expand All @@ -68,11 +85,6 @@ module.exports = function(grunt) {
message: 'Line 1\nLine 2\nLine3\nLine 4\nLine 5.'
}
}
},

// Unit tests.
nodeunit: {
tests: ['test/*_test.js']
}

});
Expand All @@ -82,12 +94,12 @@ module.exports = function(grunt) {

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-cafe-mocha');
grunt.loadNpmTasks('grunt-contrib-watch');

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['notify', 'nodeunit']);
grunt.registerTask('test', ['notify', 'cafemocha']);

// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ I've changed the default icon which is owned by Apple to the Grunt logo.
This project was created for and is used by the free game I co-created for Node Knockout called [Doodle or Die](http://doodleOrDie.com). Please give it a try, we think you will enjoy it!

## Release History
* 17 August 2013 - 0.2.8
* Fixed bug caused Grunt-Notify to not work in 32-bit windows.
* Fixed bug that prevented Snarl from working if the task ended quickly from an error.
* Removed defaults for how many notifications and how long notifications say on the screen for Snarl.
* Replaced Nodeunit tests with Mocha tests.
* 29 July 2013 - 0.2.7
* Fixed bug that could prevent Growl from working.
* 26 July 2013 - 0.2.5
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-notify",
"description": "Automatic desktop notifications for Grunt errors and warnings using Growl for OS X or Windows, Mountain Lion Notification Center, and Notify-Send.",
"version": "0.2.7",
"version": "0.2.8",
"homepage": "https://github.com/dylang/grunt-notify",
"author": {
"name": "Dylan Greene",
Expand Down Expand Up @@ -29,8 +29,9 @@
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6.2",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-watch": "~0.5.1"
"grunt-contrib-watch": "~0.5.1",
"grunt-cafe-mocha": "~0.1.8",
"chai": "~1.7.2"
},
"peerDependencies": {
"grunt": "~0.4.1"
Expand All @@ -50,6 +51,6 @@
"dependencies": {
"stack-parser": "~0.0.1",
"which": "~1.0.5",
"semver": "~1.1.4"
"semver": "~2.1.0"
}
}
2 changes: 2 additions & 0 deletions tasks/lib/hooks/notify-jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ module.exports = function(grunt, options) {
message.trim()
].join('\n')
});

console.log('========', message.trim());
lineNumber = false;
reason = false;
}
Expand Down
40 changes: 20 additions & 20 deletions tasks/lib/platforms/hey-snarl.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ var cmd = 'heysnarl.exe';

var IS_WINDOWS = os.type() === 'Windows_NT';
var DEFAULT_IMAGE = path.resolve(__dirname + '../../../../images/grunt-logo.png');
var DEFAULT_TIMEOUT = 2;
var DEFAULT_PRIORITY = 0;

function findInstall() {

var INSTALL_DIR = path.join('full phat', 'Snarl', 'tools');
var full_path = path.join(process.env.ProgramFiles, INSTALL_DIR, cmd);
var full_path_x86 = path.join(process.env['ProgramFiles(x86)'], INSTALL_DIR, cmd);
var PROGRAM_FILES = process.env.ProgramFiles || '';
var PROGRAM_FILES_X86 = process.env['ProgramFiles(x86)'] || '';
var full_path = path.join(PROGRAM_FILES, INSTALL_DIR, cmd);
var full_path_x86 = path.join(PROGRAM_FILES_X86, INSTALL_DIR, cmd);

return cmd = findApp(cmd) ||
findApp(full_path) ||
Expand All @@ -35,24 +35,24 @@ function isSupported() {
return IS_WINDOWS && findInstall();
}

module.exports = isSupported() && function(options, cb) {
function escape(str) {
return str.replace(/&/g, '&&').substr(0, 60);
}

var params = url.format({
pathname: 'notify',
query: {
title: options.title,
text: options.message,
icon: options.image || DEFAULT_IMAGE,
timeout: options.timeout || DEFAULT_TIMEOUT,
priority: options.priority || DEFAULT_PRIORITY
function notify(options, cb) {
var params =
'notify?' +
'title=' + escape(options.title) + '&' +
'text=' + escape(options.message) + '&' +
'icon=' + (options.image || DEFAULT_IMAGE);

spawn(cmd, [params], function(err, result, code){
if (typeof cb === 'function') {
cb();
}
});
}

// don't want the windows version of newline
params = params.replace(/\%0A/g, '\n');

spawn(cmd, [params], function(err){
// heysnarl seems to sends err even when it doesn't need to
cb();
});
module.exports = isSupported() && function(options, cb) {
notify(options, cb); //, function(){
};
17 changes: 7 additions & 10 deletions tasks/lib/util/spawn.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
'use strict';

var grunt = require('grunt');
var spawn = require('child_process').spawn;

module.exports = function(cmd, args, cb){

var options = {
detached: true
detached: true,
stdio: [ 'ignore','ignore', 'ignore' ]
};

grunt.util.spawn({
cmd: cmd,
args: args,
options: options
}, function(err, result, code){
if (cb) {
cb(err);
}
});
var child = spawn(cmd, args, options);

child.on('close', function (code) {
cb(code);
});
};


3 changes: 2 additions & 1 deletion tasks/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ module.exports = function gruntTask(grunt) {
grunt.registerMultiTask('notify', 'Show an arbitrary notification whenever you need.', function() {
var options = this.options(defaults);

var done = this.async();
if (options.message) {
notify(options);
notify(options, done);
}
grunt.log.debug('Notify options:', options);
});
Expand Down
34 changes: 34 additions & 0 deletions test/notify.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';
var expect = require('chai').expect;

var grunt = require('grunt');
var notify = require('../tasks/lib/notify');


describe('grunt-notify', function () {
describe('sanity checks', function () {
it('notify', function (done) {
notify({ title: 'title', message: 'message' }, function(err){
if (err) throw err;
//expect(err).to.be.empty;
done();
});
});

it('weird chars', function (done) {
notify({ title: 'weird chars', message: 'bang! "quotes" [brackets] &and&' }, function(err){
if (err) throw err;
//expect(err).to.be.;
done();
});
});

it('notify', function (done) {
notify({ title: 'title' }, function(err){
expect(err).to.equal('Message is required');
done();
});
});

});
});
59 changes: 0 additions & 59 deletions test/notify_test.js

This file was deleted.

0 comments on commit 90783c3

Please sign in to comment.