Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 37x 4x 4x 4x 8x 8x 8x 4x 4x 4x 4x 4x 8x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 37x | const utils = require('./utils.js'); class Executor { constructor (iterator, maltaInstance, pmInstance) { this.iterator = iterator; this.malta = maltaInstance; this.pm = pmInstance; } run () { const malta = this.malta, self = this; if (this.iterator.hasNext()) { const ext = this.iterator.next(), pins = this.pm.plugins[ext] || []; Eif (malta.outName.match(new RegExp(`.*\\.${ext}$`))) { const iterator = utils.getIterator(pins); (function go () { let res, pl; if (iterator.hasNext()) { pl = iterator.next(); res = self.callPlugin(pl); Eif (res) { (new Promise(res)).then(obj => { if (malta.userWatch) malta.userWatch.call(malta, obj, pl); malta.data.name = obj.name; // replace the name given by the plugin fo the file // produced and to be passed to the next plugin // malta.data.content = `${obj.content}`; go(); }).catch(msg => { self.pm.maybeNotifyBuild({ gotErrs: msg }); malta.log_debug(`Plugin '${pl.name}' error: `); malta.log_debug(msg); go(); }); } else { go(); } } else { self.run(); } })(); } else { this.run(); } } else { if (typeof malta.endCb === 'function') malta.endCb(malta.data); this.pm.maybeNotifyBuild(); } } callPlugin (p) { const malta = this.malta; malta.log_debug([ '> ', p.name.yellow(), (p.params ? `called passing ${JSON.stringify(p.params).darkgray()}` : '') ].join('')); malta.doBuild = true; // actually I dont` need to pass data, since it can be retrieved by the context, // but is better (and I don`t have to modify every plugin and the documentation) // return p.func.bind(malta)(malta.data, p.params); } } module.exports = Executor; |