Comparing version 0.2.0 to 0.2.1
27
index.js
@@ -315,4 +315,17 @@ // YAML.node, © 2012 Stéphan Kochen | ||
fs.readFile(filename, 'utf-8', function(err, data) { | ||
if (err) callback(err, null); | ||
else callback(null, YAML.parse(data, tagHandlers)); | ||
if (err) { | ||
callback(err, null); | ||
return; | ||
} | ||
var documents; | ||
try { | ||
documents = YAML.parse(data, tagHandlers); | ||
} | ||
catch (err) { | ||
callback(err, null); | ||
return; | ||
} | ||
callback(null, documents); | ||
}); | ||
@@ -413,3 +426,11 @@ }; | ||
var data = YAML.stringify.apply(this, documents); | ||
var data; | ||
try { | ||
data = YAML.stringify.apply(this, documents); | ||
} | ||
catch (err) { | ||
callback(err, null); | ||
return; | ||
} | ||
fs.writeFile(filename, data, callback); | ||
@@ -416,0 +437,0 @@ }; |
{ | ||
"name": "libyaml", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Bindings to libYAML", | ||
@@ -5,0 +5,0 @@ |
@@ -1,5 +0,7 @@ | ||
**YAML.node** is a simple binding for LibYAML. [![Build Status](https://secure.travis-ci.org/stephank/yaml.node.png)](http://travis-ci.org/stephank/yaml.node) | ||
## YAML.node [![Build Status](https://secure.travis-ci.org/stephank/yaml.node.png)](http://travis-ci.org/stephank/yaml.node) | ||
Make sure you're on Node.js 0.4 or 0.6, and have LibYAML headers installed. Then simply: | ||
A simple binding for LibYAML. | ||
### Installing | ||
$ npm install libyaml | ||
@@ -33,4 +35,11 @@ | ||
### Upgrading | ||
### Hacking the code | ||
git clone https://github.com/stephank/yaml.node.git | ||
cd yaml.node | ||
npm install | ||
npm test | ||
### Upgrading from pre-0.1.0 | ||
As of 0.1.0, the API immitates the JavaScript built-in `JSON` parser for string handling, and the | ||
@@ -49,8 +58,1 @@ Node.js built-in `fs`-module for file I/O. Function names have changed as follows: | ||
YAML.parse ➞ YAML.stream.parse | ||
### Hacking the code | ||
git clone https://github.com/stephank/yaml.node.git | ||
cd yaml.node | ||
npm install | ||
npm test |
@@ -16,2 +16,11 @@ var test = require('tap').test; | ||
test('bad parser input async', function(t) { | ||
t.plan(1); | ||
YAML.readFile(testutil.inputPath('badinput'), function(err) { | ||
t.equal(err.message, | ||
"did not find expected key, while parsing a block mapping, on line 2"); | ||
}); | ||
}); | ||
test('bad emitter input', function(t) { | ||
@@ -18,0 +27,0 @@ t.plan(1); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2787785
1230
57
1