diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-22 13:54:52 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-22 13:54:52 +0100 |
commit | 71144db09c150f6499d977863dbccf12ce05638b (patch) | |
tree | 690d9c6fff23e3a2b33493be6f5d16602240a9c1 /lib/plugins/context.js | |
parent | 395bd62663614c79181e3e27049345231186339b (diff) | |
download | gitbook-71144db09c150f6499d977863dbccf12ce05638b.zip gitbook-71144db09c150f6499d977863dbccf12ce05638b.tar.gz gitbook-71144db09c150f6499d977863dbccf12ce05638b.tar.bz2 |
Normalize context for plugins
Diffstat (limited to 'lib/plugins/context.js')
-rw-r--r-- | lib/plugins/context.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/plugins/context.js b/lib/plugins/context.js new file mode 100644 index 0000000..51649aa --- /dev/null +++ b/lib/plugins/context.js @@ -0,0 +1,24 @@ +var error = require('../utils/error'); + +/* + Return the context for a plugin. + It tries to keep compatibilities with GitBook v2 +*/ + +function pluginCtx(plugin) { + var book = plugin.book; + var ctx = { + config: book.config, + log: plugin.log, + + // Paths + resolve: book.resolve + }; + + // Deprecation + error.deprecateField(ctx, 'options', book.config.dump(), '"options" property is deprecated, use config.get(key) instead'); + + return ctx; +} + +module.exports = pluginCtx; |