Skip to content

Commit

Permalink
Fix for readYAML error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
shama committed Apr 14, 2016
1 parent 8ada494 commit 3484b83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/grunt/file.js
Expand Up @@ -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);
}
};

Expand Down
8 changes: 7 additions & 1 deletion test/grunt/file_test.js
Expand Up @@ -452,14 +452,20 @@ 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.');

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.');
Expand Down

0 comments on commit 3484b83

Please sign in to comment.