Skip to content

Commit

Permalink
assignInFile can write to different file
Browse files Browse the repository at this point in the history
  • Loading branch information
honzabrecka committed Feb 24, 2016
1 parent ee37662 commit 85de6a2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ function assign(template, assigns, keyMaker, valueMaker) {
}

function assignInFile(file, assigns, keyMaker, valueMaker) {
return fs.readFileAsync(file, encoding)
const input = Array.isArray(file) ? file[0] : file;
const output = Array.isArray(file) ? file[1] : file;

return fs.readFileAsync(input, encoding)
.then((content) => assign(content, assigns, keyMaker, valueMaker))
.then((content) => fs.writeFileAsync(file, content, encoding));
.then((content) => fs.writeFileAsync(output, content, encoding));
}

function md5FileHash(file) {
Expand Down

0 comments on commit 85de6a2

Please sign in to comment.