bem-site / bem-forum-content-ru

Content BEM forum for Russian speak users
MIT License
56 stars 6 forks source link

Помогите пожалуйста найти ошибку #870

Open rustam-mh opened 8 years ago

rustam-mh commented 8 years ago

var fs = require('fs'), path = require('path'), vm = require('vm'), vow = require('vow');

    var Bundle = function(name, folder){
        this.name = name+'.bundles';
        this.folder = folder;   
        this.path = path.join(this.name,this.folder,this.folder);
        this.BEMTREE = this.bemtree();
        this.BEMHTML = require('../../../' + this.path + '.bemhtml.js');
    };

    Bundle.prototype.bemtree = function(){
         var bemtreePath = './' + this.path + '.bemtree.js',
         bemtreeFile = fs.readFileSync(bemtreePath, 'utf-8'),
         context = vm.createContext({
            console: console,
                Vow: vow,
                require: require,
            setImmediate: setImmediate          
        });

        vm.runInContext(bemtreeFile, context);
        return context.BEMTREE;
    };
    module.exports = Bundle;

    var Bundle = require('../server/libs/bem');
    var index = new Bundle('desktop', 'index');

    index.BEMTREE.apply({ block: 'header' }).then(function(bemjson){
        console.log(bemjson);
    });

evalmachine.:1823 throw new Error(msg || 'Assertion failed'); ^

Error: Wrong .match() argument at assert (evalmachine.:1823:11) at Tree.match (evalmachine.:1613:5) at Object. (evalmachine.:1967:1) at Tree.build (evalmachine.:1517:13) at BEMHTML.compile (evalmachine.:372:18) at buildBemXjst (evalmachine.:1844:5) at evalmachine.:2080:15 at evalmachine.:2083:3 at Object.exports.runInContext (vm.js:44:17) at Bundle.bemtree (/home/rustam/www/rhblog/server/libs/bem/index.js:24:5)

qfox commented 8 years ago

в каком-то из шаблонов в .match не функция?

tadatuta commented 8 years ago

Не обязательно в match(), может быть в любой из «сахарных» функций (tag(), attrs() и т.д.).

Могу помочь найти точное места, если опубликуешь собранный бандл и входные данные.

rustam-mh commented 8 years ago

index.bemjson.js:

    `module.exports = {block : 'header'};`

bundle.js:

       var fs = require('fs');
       var path = require('path');
       var vm = require('vm');
       var vow = require('vow');

       var Bundle = function(name, folder){
         this.name = name+'.bundles';
         this.folder = folder;    
         this.path = path.join(this.name,this.folder,this.folder);
         this.BEMTREE = this.bemtree();
         this.BEMHTML = require('../../../' + this.path + '.bemhtml.js');
        };

        Bundle.prototype.bemtree = function(){
             var bemtreePath = './' + this.path + '.bemtree.js',
             bemtreeFile = fs.readFileSync(bemtreePath, 'utf-8'),
             context = vm.createContext({
                        console: console,
                     Vow: vow,
                     require: require,
                 setImmediate: setImmediate           
              });
              vm.runInContext(bemtreeFile, context);
              return context.BEMTREE;
         };
         module.exports = Bundle;

test.js:

var Bundle = require('../server/libs/bem');
            var index = new Bundle('desktop', 'index');
            index.BEMTREE.apply({ block: 'header' }).then(function(bemjson){
                      console.log( index.BEMHTML.apply(bemjson) );
            });

throw new Error(msg || 'Assertion failed'); ^

Error: Wrong .match() argument at assert (/home/rustam/my-bem-project/desktop.bundles/index/index.bemtree.js:1823:11) at Tree.match (/home/rustam/my-bem-project/desktop.bundles/index/index.bemtree.js:1613:5) at Object. (/home/rustam/my-bem-project/desktop.bundles/index/index.bemtree.js:1967:1) at Tree.build (/home/rustam/my-bem-project/desktop.bundles/index/index.bemtree.js:1517:13) at BEMHTML.compile (/home/rustam/my-bem-project/desktop.bundles/index/index.bemtree.js:372:18) at buildBemXjst (/home/rustam/my-bem-project/desktop.bundles/index/index.bemtree.js:1844:5) at /home/rustam/my-bem-project/desktop.bundles/index/index.bemtree.js:2044:26 at Object. (/home/rustam/my-bem-project/desktop.bundles/index/index.bemtree.js:2057:3) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10)

tadatuta commented 8 years ago

я про /home/rustam/my-bem-project/desktop.bundles/index/index.bemtree.js говорил