Skip to content

Commit

Permalink
Fixed "readFileSync" example
Browse files Browse the repository at this point in the history
The method `fs.readFileSync` returns a Buffer when no encoding is specified (https://nodejs.org/api/fs.html#fs_fs_readfilesync_file_options) and this causes the `SourceMapConsumer` to fail because it expects a string to execute `JSON.parse`. Therefore an encoding needs to be specified, otherwise SourceMapsConsumer fails with `Error: "version" is a required argument`.
  • Loading branch information
bennycode committed Jun 14, 2016
1 parent aa0398c commit be7445a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -566,7 +566,7 @@ Creates a SourceNode from generated code and a SourceMapConsumer.
should be relative to.

```js
var consumer = new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map"));
var consumer = new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8"));
var node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"),
consumer);
```
Expand Down

0 comments on commit be7445a

Please sign in to comment.