Plugins and tools in HonKit 8
HonKit 8 returns native promises to plugins and to tools that use HonKit as a library (require("honkit")).
HonKit 7 added the methods of the Q library to these promises, because plugins that were written for GitBook call them. HonKit 8 removes them.
A plugin is affected only when it calls one of these methods on a promise that HonKit returns, for example this.readFileAsString(), this.renderBlock(), this.renderInline(), this.template.applyBlock() or this.output.writeFile().
Promises that the plugin creates itself are not changed.
Replace the methods
| HonKit 7 | HonKit 8 |
|---|---|
promise.fail(fn) |
promise.catch(fn) |
promise.fin(fn) |
promise.finally(fn) |
promise.thenResolve(value) |
promise.then(() => value) |
promise.spread((a, b) => ...) |
promise.then(([a, b]) => ...) |
promise.tap(fn) |
promise.then(async (value) => { await fn(value); return value; }) |
promise.nodeify(callback) |
promise.then((value) => callback(null, value), (error) => callback(error)) |
promise.progress(fn) |
remove the call: it did nothing |
The replacements work in HonKit 7 too, so a plugin can support both versions.
Find the calls
The call fails with an error such as this.readFileAsString(...).fail is not a function.
To find the calls before the update, search the source of the plugin:
$ grep -rnE "\.(fail|fin|thenResolve|spread|tap|nodeify|progress)\(" index.js lib/