| 34 | }; |
| 35 | |
| 36 | const normMethods = plugin => { |
| 37 | const methods = {}; |
| 38 | methods.lint = methods.getDependencies = [bind, promisify(false), thenify, warnIfLong]; |
| 39 | methods.compile = methods.optimize = [bind, promisify(true), thenify, wrapStrings, warnIfLong]; |
| 40 | methods.compileStatic = [bind, thenify, wrapStrings, warnIfLong]; |
| 41 | |
| 42 | Object.keys(methods).forEach(key => { |
| 43 | const fn = plugin[key]; |
| 44 | if (typeof fn !== 'function') return; |
| 45 | |
| 46 | const decorators = methods[key]; |
| 47 | const compose = (fn, decorator) => decorator(fn, plugin, key); |
| 48 | const value = decorators.reduce(compose, fn); |
| 49 | |
| 50 | Object.defineProperty(plugin, key, {value}); |
| 51 | }); |
| 52 | }; |
| 53 | |
| 54 | const bind = (fn, plugin) => fn.bind(plugin); |
| 55 | const promisify = returnsFile => fn => { |
no test coverage detected
searching dependent graphs…