Permalink
Browse files

last dump

  • Loading branch information...
1 parent 5573155 commit df46829a9b7a7c2a344afcafcb2fc61f4003f425 @deepsweet deepsweet committed with arikon Mar 29, 2013
Showing with 68 additions and 25 deletions.
  1. +15 −2 lib/techs/deps.js.js
  2. +53 −23 lib/techs/js.js
View
17 lib/techs/deps.js.js
@@ -193,8 +193,21 @@ var Deps = exports.Deps = INHERIT({
},
parseFull: function(deps) {
- // TODO: deep copy
- deps && (this.items = deps);
+ if (deps) {
+ var items = {};
+
+ Object.keys(deps).forEach(function(k) {
+ items[k] = new DepsItem({}, deps[k]);
+ // TODO: upyachka!!!11
+ items[k].shouldDeps = deps[k].shouldDeps;
+ items[k].mustDeps = deps[k].mustDeps;
+ });
+
+ this.items = items;
+ }
+
+ // console.log(this.items);
+
return this;
},
View
76 lib/techs/js.js
@@ -1,41 +1,71 @@
var FS = require('fs'),
DEPS = require('../techs/deps.js'),
- Q = require('q');
+ Q = require('q'),
+ PATH = require('../path'),
+ U = require('../util');
exports.techMixin = {
- // buildByDecl: function(decl, levels, output) {
- // // TODO
- // },
+ buildByDecl: function(decl, levels, output) {
- transformBuildDecl: function(decl) {
+ var jsTechDecl = this.transformTechBuildDecl(decl, 'js'),
+ bemhtmlTechDecl = this.transformTechBuildDecl(decl, 'bemhtml', 'js');
- return this.getContext().opts.declaration.then(function(decl) {
- // console.log(JSON.stringify(decl.depsByTechs, null, 4) + '\n');
+ jsTechDecl.then(function(d) { console.log(d); });
+ bemhtmlTechDecl.then(function(d) { console.log(d); });
- var deps = new DEPS.Deps().parseFull(decl.depsFull),
- decl = [];
+ return Q.all([
+ this.getTechBuildResult('js', jsTechDecl, levels, output)
+ .then(function(res) {
+ console.log(res);
+ }),
- console.log(JSON.stringify(deps, null, 4) + '\n');
+ this.getTechBuildResult('bemhtml', bemhtmlTechDecl, levels, output)
+ .then(function(res) {
+ console.log(res);
+ })
+ ]);
- deps.forEach(function(item, ctx) {
+ },
- var tCtx = ctx.item.tech || '',
- tItem = item.item.tech || '';
+ getTechBuildResult: function(tech, decl, levels, output) {
- if (!tItem || tItem == 'js' || (tItem == 'bemhtml' && tCtx == 'js')) {
- decl.push(item.item);
- }
+ var t = this
+ .getContext()
+ .getTech(tech);
- // console.log('i=%j\nc=%j\n%s %s\n---', item.item, ctx.item, t1, t2);
- });
+ return t.getBuildResults(t.getBuildPrefixes(decl, levels),
+ PATH.dirname(output) + PATH.dirSep, PATH.basename(output));
+
+ },
+
+ transformTechBuildDecl: function(decl, tech, ctxTech) {
+
+ return this.getContext().opts.declaration
+ .then(function(decl) {
- // console.log(deps.items);
- // console.log('---');
- console.log(decl);
+ var deps = new DEPS.Deps().parseFull(decl.depsFull),
+ decl = [],
+ uniq = [];
- return { deps: decl };
- });
+ deps.forEach(function(item, ctx) {
+
+ var tCtx = ctx.item.tech || '',
+ tItem = item.item.tech || '',
+ key = U.bemKey(item.item);
+
+ if ((!tItem || tItem == tech) && (!ctxTech || ctxTech == tCtx)) {
+ if (!~uniq.indexOf(key)) {
+ decl.push(item.item);
+ uniq.push(key);
+ }
+ }
+
+ });
+
+ return { deps: decl };
+
+ });
},

0 comments on commit df46829

Please sign in to comment.