Permalink
Browse files

escaped $ in growl messages

  • Loading branch information...
magnars committed Jun 24, 2011
1 parent 8d476fb commit 57c6abb19cc9c67fd89d364f47dbc5f2bd0732b1
File renamed without changes
File renamed without changes
View
@@ -13,15 +13,23 @@ function listen() {
this.repository.on('errorsFixed', this.handleErrorsFixed.bind(this));
}
+function escape(text) {
+ return text.replace('$', '\\$');
+}
+
+function notify(title, text, icon) {
+ growl.notify(escape(text), {
+ title: escape(title),
+ image: __dirname + '/../icons/' + icon + '.png'
+ });
+}
+
function handleErrorsIntroduced(file, errors) {
var error = 'First error at line ' + errors[0].line +
' char ' + errors[0].character +
':\n' + errors[0].reason;
var title = 'You introduced ' + pluralize(errors.length, 'lint error') + ' in ' + file.name + ':';
- growl.notify(error, {
- title: title,
- image: __dirname + '/../icons/no.png'
- });
+ notify(title, error, 'error');
}
var cheers = [
@@ -52,22 +60,15 @@ function cheer() {
}
function congratulate(file) {
- growl.notify(file.name + ' is clean.', {
- title: cheer(),
- image: __dirname + '/../icons/ok.png'
- });
+ notify(cheer(), file.name + ' is clean.', 'clean');
}
function nextError(file) {
var error = file.errors[0];
var text = 'Next error at line ' + error.line +
' char ' + error.character +
':\n' + error.reason;
- var title = 'Nice cleanup!';
- growl.notify(text, {
- title: title,
- image: __dirname + '/../icons/more.png'
- });
+ notify('Nice cleanup!', text, 'more');
}
function handleErrorsFixed(file, fixedError) {
@@ -67,5 +67,11 @@ buster.testCase("growlReporter", {
reason: 'Bah, humbug!'
}]}, [{}]);
assert.calledWith(growl.notify, 'Next error at line 19 char 0:\nBah, humbug!');
+ },
+
+ "should escape $": function () {
+ this.reporter.handleErrorsFixed({name: 'file$.js', errors: []}, [{}]);
+ assert.calledWith(growl.notify, 'file\\$.js is clean.');
}
+
});
View
@@ -1,7 +1,5 @@
Todo
====
-* `$` needs to be escaped in growl messages
-
* being blamed for introducing an error, AND praised for fixing it,
when changing around whitespace (changes lines)

0 comments on commit 57c6abb

Please sign in to comment.