Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Merge pull request #8 from elwynelwyn/master
Browse files Browse the repository at this point in the history
Fixed bug where `replaceMap` option was ignored
  • Loading branch information
jackfranklin authored Jan 3, 2017
2 parents cc6a070 + a8ddc6c commit 0cf30b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ var options = {
replaceMap: {
foo: 'bar'
}
// or, specify a path to your replaceMap json file
// replaceMapPath: './map.json'
};

replaceinfiles(options)
Expand All @@ -142,3 +144,4 @@ replaceinfiles(options)
// ...
});
```
If you do not specify `replaceMap` or `replaceMapPath` then `stdin` will be used.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function runPaths(sourcePaths, options) {
module.exports = function run(options) {
return Promise.all([
listPaths(options.source),
getReplaceMap(options.encoding, options.replaceMapPath)
getReplaceMap(options.encoding, options.replaceMapPath, options.replaceMap)
]).then(function(results){
var sourcePaths = results[0];
var replaceMap = results[1];
Expand Down
7 changes: 6 additions & 1 deletion lib/getReplaceMap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
var fs = require('fs');

module.exports = function getReplaceMap(encoding, path) {
module.exports = function getReplaceMap(encoding, path, replaceMap) {
if (path && replaceMap) {
return Promise.reject(new Error('Cannot specify both replaceMapPath and replaceMap.'));
} else if (replaceMap) {
return Promise.resolve(replaceMap);
}
return getReadStreamOrStdin(encoding, path)
.then(parseStreamToJSON);
}
Expand Down

0 comments on commit 0cf30b9

Please sign in to comment.