|
4 | 4 | * Module dependencies. |
5 | 5 | */ |
6 | 6 |
|
7 | | -var exec = require('child_process').exec |
| 7 | +var spawn = require('child_process').spawn |
8 | 8 | , fs = require('fs') |
9 | 9 | , path = require('path') |
10 | 10 | , exists = fs.existsSync || path.existsSync |
11 | 11 | , os = require('os') |
12 | | - , quote = JSON.stringify |
13 | 12 | , cmd; |
14 | 13 |
|
15 | 14 | function which(name) { |
@@ -127,7 +126,7 @@ exports = module.exports = growl; |
127 | 126 | * Node-growl version. |
128 | 127 | */ |
129 | 128 |
|
130 | | -exports.version = '1.4.1' |
| 129 | +exports.version = '1.9.3' |
131 | 130 |
|
132 | 131 | /** |
133 | 132 | * Send growl notification _msg_ with _options_. |
@@ -189,18 +188,18 @@ function growl(msg, options, fn) { |
189 | 188 | flag = flag || /^png|gif|jpe?g$/.test(ext) && 'image' |
190 | 189 | flag = flag || ext && (image = ext) && 'icon' |
191 | 190 | flag = flag || 'icon' |
192 | | - args.push('--' + flag, quote(image)) |
| 191 | + args.push('--' + flag, image) |
193 | 192 | break; |
194 | 193 | case 'Darwin-NotificationCenter': |
195 | | - args.push(cmd.icon, quote(image)); |
| 194 | + args.push(cmd.icon, image); |
196 | 195 | break; |
197 | 196 | case 'Linux': |
198 | | - args.push(cmd.icon, quote(image)); |
| 197 | + args.push(cmd.icon, image); |
199 | 198 | // libnotify defaults to sticky, set a hint for transient notifications |
200 | 199 | if (!options.sticky) args.push('--hint=int:transient:1'); |
201 | 200 | break; |
202 | 201 | case 'Windows': |
203 | | - args.push(cmd.icon + quote(image)); |
| 202 | + args.push(cmd.icon + image); |
204 | 203 | break; |
205 | 204 | } |
206 | 205 | } |
@@ -230,61 +229,61 @@ function growl(msg, options, fn) { |
230 | 229 | switch(cmd.type) { |
231 | 230 | case 'Darwin-Growl': |
232 | 231 | args.push(cmd.msg); |
233 | | - args.push(quote(msg).replace(/\\n/g, '\n')); |
234 | | - if (options.title) args.push(quote(options.title)); |
| 232 | + args.push(msg.replace(/\\n/g, '\n')); |
| 233 | + if (options.title) args.push(options.title); |
235 | 234 | break; |
236 | 235 | case 'Darwin-NotificationCenter': |
237 | 236 | args.push(cmd.msg); |
238 | | - var stringifiedMsg = quote(msg); |
| 237 | + var stringifiedMsg = msg; |
239 | 238 | var escapedMsg = stringifiedMsg.replace(/\\n/g, '\n'); |
240 | 239 | args.push(escapedMsg); |
241 | 240 | if (options.title) { |
242 | 241 | args.push(cmd.title); |
243 | | - args.push(quote(options.title)); |
| 242 | + args.push(options.title); |
244 | 243 | } |
245 | 244 | if (options.subtitle) { |
246 | 245 | args.push(cmd.subtitle); |
247 | | - args.push(quote(options.subtitle)); |
| 246 | + args.push(options.subtitle); |
248 | 247 | } |
249 | 248 | if (options.url) { |
250 | 249 | args.push(cmd.url); |
251 | | - args.push(quote(options.url)); |
| 250 | + args.push(options.url); |
252 | 251 | } |
253 | 252 | break; |
254 | 253 | case 'Linux-Growl': |
255 | 254 | args.push(cmd.msg); |
256 | | - args.push(quote(msg).replace(/\\n/g, '\n')); |
257 | | - if (options.title) args.push(quote(options.title)); |
| 255 | + args.push(msg.replace(/\\n/g, '\n')); |
| 256 | + if (options.title) args.push(options.title); |
258 | 257 | if (cmd.host) { |
259 | 258 | args.push(cmd.host.cmd, cmd.host.hostname) |
260 | 259 | } |
261 | 260 | break; |
262 | 261 | case 'Linux': |
263 | 262 | if (options.title) { |
264 | | - args.push(quote(options.title)); |
| 263 | + args.push(options.title); |
265 | 264 | args.push(cmd.msg); |
266 | | - args.push(quote(msg).replace(/\\n/g, '\n')); |
| 265 | + args.push(msg.replace(/\\n/g, '\n')); |
267 | 266 | } else { |
268 | | - args.push(quote(msg).replace(/\\n/g, '\n')); |
| 267 | + args.push(msg.replace(/\\n/g, '\n')); |
269 | 268 | } |
270 | 269 | break; |
271 | 270 | case 'Windows': |
272 | | - args.push(quote(msg).replace(/\\n/g, '\n')); |
273 | | - if (options.title) args.push(cmd.title + quote(options.title)); |
274 | | - if (options.url) args.push(cmd.url + quote(options.url)); |
| 271 | + args.push(msg.replace(/\\n/g, '\n')); |
| 272 | + if (options.title) args.push(cmd.title + options.title); |
| 273 | + if (options.url) args.push(cmd.url + options.url); |
275 | 274 | break; |
276 | 275 | case 'Custom': |
277 | 276 | args[0] = (function(origCommand) { |
278 | 277 | var message = options.title |
279 | 278 | ? options.title + ': ' + msg |
280 | 279 | : msg; |
281 | | - var command = origCommand.replace(/(^|[^%])%s/g, '$1' + quote(message)); |
282 | | - if (command === origCommand) args.push(quote(message)); |
| 280 | + var command = origCommand.replace(/(^|[^%])%s/g, '$1' + message); |
| 281 | + if (command === origCommand) args.push(message); |
283 | 282 | return command; |
284 | 283 | })(args[0]); |
285 | 284 | break; |
286 | 285 | } |
287 | | - |
288 | | - // execute |
289 | | - exec(args.join(' '), fn); |
| 286 | + var cmd_to_exec = args[0]; |
| 287 | + args.shift(); |
| 288 | + spawn(cmd_to_exec, args); |
290 | 289 | }; |
0 commit comments