diff --git a/lib/techs/deps.js.js b/lib/techs/deps.js.js index a78e0fbb..6d62ce29 100644 --- a/lib/techs/deps.js.js +++ b/lib/techs/deps.js.js @@ -359,16 +359,21 @@ var DepsItem = exports.DepsItem = INHERIT({ this.item = {}; this.extendByCtx({ item: item }); this.extendByCtx(ctx); + }, extendByCtx: function(ctx) { if(ctx && (ctx = ctx.item)) { - var ks = ['tech', 'block', 'elem', 'mod', 'val'], - k; + var keys = ['block', 'elem', 'mod', 'val'], + key; - while(k = ks.shift()) - if(this.item[k]) break; - else ctx[k] && (this.item[k] = ctx[k]); + if (!this.item.tech && ctx.tech) { + this.item.tech = ctx.tech; + } + while (key = keys.shift()) { + if(this.item[key]) break; + else ctx[key] && (this.item[key] = ctx[key]); + } } return this; }, diff --git a/test/deps.js b/test/deps.js index faf2529e..6fdb7f06 100644 --- a/test/deps.js +++ b/test/deps.js @@ -133,6 +133,15 @@ describe('Deps', function() { } } )); + it('block with tech shortcut', assertDepsParse( + {block: 'b1', tech: 't1', shouldDeps: {tech: 't2'}}, + { 't1': { + 't1': [ { block: 'b1', tech: 't1'} ], + 't2': [ { block: 'b1', tech: 't2'} ] + } + } + )); + it('block with and without tech', assertDepsParse( { block: 'b1', shouldDeps: { block: 'b2', tech: 't2', shouldDeps: { block: 'b3' } } }, { '': {