Skip to content

Commit

Permalink
fix(functions): includes - pass whole context (with all consants) to …
Browse files Browse the repository at this point in the history
…the next expand level
  • Loading branch information
arlac77 committed Jan 4, 2017
1 parent 8cca639 commit 4af07e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export const functions = {
0].value);

return createValue(readFile(file).then(data =>
expand(JSON.parse(data), {
constants: {
expand(JSON.parse(data), Object.assign({}, context, {
constants: Object.assign({}, context.constants, {
basedir: path.dirname(file)
}
})
})
}))
));
}
},
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/first.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"first_key": "${include('other.json')}"
"first_key": "${include(nameOfTheOther)}"
}
1 change: 1 addition & 0 deletions tests/simple_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ describe('expander', () => {

it('can nest includes', () => expand("${include('fixtures/first.json')}", {
constants: {
nameOfTheOther: 'other.json',
basedir: __dirname
}
}).then(r => assert.deepEqual(r, {
Expand Down

0 comments on commit 4af07e8

Please sign in to comment.