Skip to content

Commit

Permalink
Merge pull request #2 from bzabos/master
Browse files Browse the repository at this point in the history
Swapping to deeply nested merge rather than top-level.
  • Loading branch information
alexlafroscia authored Jan 4, 2017
2 parents ef68524 + ec04929 commit 2e478c6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function readAsJSON(fileName) {
function yamlMerge(...from) {
const files = from.map((path) => readAsJSON(path));

const outputJSON = _.assign({}, ...files);
const outputJSON = _.merge({}, ...files);
return jsYaml.dump(outputJSON);
}

Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/merge/a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
key:
first_value: a

3 changes: 3 additions & 0 deletions test/fixtures/merge/b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
key:
second_value: b

10 changes: 10 additions & 0 deletions test/lib-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,15 @@ describe('merge logic', function() {
value: c
` + '\n');
});

it('allows keys to trickle in from all merge sources', function () {
const output = merge(...fixtureFiles('merge/a.yml', 'merge/b.yml'));

expect(output).to.equal(stripIndent`
key:
first_value: a
second_value: b
` + '\n');
});
});

0 comments on commit 2e478c6

Please sign in to comment.