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

Fixed several problems running Growl for Windows #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/platforms/growl-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ function supported(options) {
return !!app;
}

function quoteIfNecessary(value) {
/* Quoting is necessary (on Windows) when the value contains a space and has not already been quoted. */
var isNecessary = IS_WINDOWS && / /.test(value) && value.substring(0, 1) !== '"'
return isNecessary ? '"' + value + '"' : value
}

function createImageArg(image) {

var imageType = '';
Expand Down Expand Up @@ -69,7 +75,7 @@ function createImageArg(image) {

if (IS_WINDOWS) {
return [
'/i:' + image
'/i:' + quoteIfNecessary(image.replace(/\\/g, '/'))
];
}

Expand All @@ -79,7 +85,7 @@ function createImageArg(image) {
function createTitleArg(title) {
if (title) {
return [
windowsOnly('/t:') + title
windowsOnly('/t:') + quoteIfNecessary(title)
];
}
return [];
Expand All @@ -88,7 +94,7 @@ function createTitleArg(title) {
function createMessageArg(message) {
return [
macOnly('-m'),
message
quoteIfNecessary(message)
];
}

Expand Down
6 changes: 6 additions & 0 deletions lib/util/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

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

module.exports = function(cmd, args, cb){
var IS_WINDOWS = os.type() === 'Windows_NT';

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

if (IS_WINDOWS) {
options.windowsVerbatimArguments = true;
}

var child = spawn(cmd, args, options);

child.on('exit', function (code) {
Expand Down