diff --git a/bemy.js b/bemy.js index f6a9cdf..85e6fcf 100644 --- a/bemy.js +++ b/bemy.js @@ -293,10 +293,22 @@ function depsToObj(data){ } function getNormalaizedDeps(data) { - var mustDeps = depsNormalize(data.mustDeps, { parseString: parseString }), - shouldDeps = depsNormalize(data.shouldDeps, { parseString: parseString }); + var mustDeps, shouldDeps; - return mustDeps.concat(shouldDeps); + if (Array.isArray(data)) { + data.forEach(function(obj){ + if (obj.mustDeps) mustDeps = obj.mustDeps; + if (obj.shouldDeps) shouldDeps = obj.shouldDeps; + }); + } else { + mustDeps = data.mustDeps; + shouldDeps = data.shouldDeps; + } + + var normalizedMustDeps = depsNormalize(mustDeps, { parseString: parseString }), + normalizedShouldDeps = depsNormalize(shouldDeps, { parseString: parseString }); + + return normalizedMustDeps.concat(normalizedShouldDeps); } function createFile(file, type, trg, modVal, cursorPos){ diff --git a/package.json b/package.json index afc40f4..32116ee 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "type": "git", "url": "https://github.com/f0rmat1k/bemy.git" }, - "version": "2.2.1", + "version": "2.2.2", "keywords": [ "bem", "BEM Tools" diff --git a/test/files-creating.js b/test/files-creating.js index 27a3056..6de419f 100644 --- a/test/files-creating.js +++ b/test/files-creating.js @@ -15,8 +15,9 @@ describe('Files creating', function(){ it ('Create task: should be correct blocks files creating', function(done){ [ 'config.json', - 'config_custon-separators.json' - ].forEach(function(configName){ + 'config_custon-separators.json', + 'config.json' + ].forEach(function(configName, i){ var configPath = path.resolve('test', configName), config = JSON.parse(fs.readFileSync(configPath, 'utf-8')), separators = config.bem.separators; @@ -27,7 +28,7 @@ describe('Files creating', function(){ fs.mkdirSync(blockDir); var deps = getDeps(separators); - createDepsTpl(deps); + createDepsTpl(deps, i); testCreatingTask(configPath); testDepsCreationFiles(deps, configPath); @@ -71,7 +72,7 @@ function testDepsCreationFiles(deps, configPath){ }); } -function createDepsTpl(deps){ +function createDepsTpl(deps, i){ var shouldDeps = Object.keys(deps).map(function(key){ return deps[key]; }); @@ -79,7 +80,13 @@ function createDepsTpl(deps){ var obj = JSON.stringify(shouldDeps); var depsPath = path.resolve('test/', 'deps-template.js'); - var depsFile = '({ shouldDeps: ' + obj + '})'; + var depsFile; + + if (i === 2) { + depsFile = '([ { tech: "js", shouldDeps: [ { block: "foo", tech: "bemhtml" } ] }, { shouldDeps: ' + obj + '} ]);'; + } else { + depsFile = '({ shouldDeps: ' + obj + '})'; + } fs.writeFileSync(depsPath, depsFile); }