50 lines
1.9 KiB
Diff
50 lines
1.9 KiB
Diff
From 3484b83a87e1f5ea689aa5aece9f9ae96151d3ff Mon Sep 17 00:00:00 2001
|
|
From: Kyle Robinson Young <kyle@dontkry.com>
|
|
Date: Wed, 13 Apr 2016 18:06:59 -0700
|
|
Subject: [PATCH] Fix for readYAML error messages
|
|
|
|
---
|
|
lib/grunt/file.js | 2 +-
|
|
test/grunt/file_test.js | 8 +++++++-
|
|
2 files changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/lib/grunt/file.js b/lib/grunt/file.js
|
|
index 303e0ab4..f8a694e5 100644
|
|
--- a/lib/grunt/file.js
|
|
+++ b/lib/grunt/file.js
|
|
@@ -262,7 +262,7 @@ file.readYAML = function(filepath, options) {
|
|
return result;
|
|
} catch (e) {
|
|
grunt.verbose.error();
|
|
- throw grunt.util.error('Unable to parse "' + filepath + '" file (' + e.problem + ').', e);
|
|
+ throw grunt.util.error('Unable to parse "' + filepath + '" file (' + e.message + ').', e);
|
|
}
|
|
};
|
|
|
|
diff --git a/test/grunt/file_test.js b/test/grunt/file_test.js
|
|
index 91466f28..19889e61 100644
|
|
--- a/test/grunt/file_test.js
|
|
+++ b/test/grunt/file_test.js
|
|
@@ -452,7 +452,7 @@ exports.file = {
|
|
test.done();
|
|
},
|
|
'readYAML': function(test) {
|
|
- test.expect(3);
|
|
+ test.expect(4);
|
|
var obj;
|
|
obj = grunt.file.readYAML('test/fixtures/utf8.yaml');
|
|
test.deepEqual(obj, this.object, 'file should be read as utf8 by default and parsed correctly.');
|
|
@@ -460,6 +460,12 @@ exports.file = {
|
|
obj = grunt.file.readYAML('test/fixtures/iso-8859-1.yaml', {encoding: 'iso-8859-1'});
|
|
test.deepEqual(obj, this.object, 'file should be read using the specified encoding.');
|
|
|
|
+ test.throws(function() {
|
|
+ obj = grunt.file.readYAML('test/fixtures/error.yaml');
|
|
+ }, function(err) {
|
|
+ return err.message.indexOf('undefined') === -1;
|
|
+ }, 'error thrown should not contain undefined.');
|
|
+
|
|
grunt.file.defaultEncoding = 'iso-8859-1';
|
|
obj = grunt.file.readYAML('test/fixtures/iso-8859-1.yaml');
|
|
test.deepEqual(obj, this.object, 'changing the default encoding should work.');
|