Yield generated for dbe41bfd-4e52-4cd1-b414-a84e6bb796d1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1.0 KiB

Plugin guide for nbx

Plugins allow you to add features to nbx, such as commands and extensions to the toolbox object that provides the majority of the functionality used by nbx.

Creating a nbx plugin is easy. Just create a repo with two folders:

commands/
extensions/

A command is a file that looks something like this:

// commands/foo.js

module.exports = {
  run: (toolbox) => {
    const { print, filesystem } = toolbox

    const desktopDirectories = filesystem.subdirectories(`~/Desktop`)
    print.info(desktopDirectories)
  }
}

An extension lets you add additional features to the toolbox.

// extensions/bar-extension.js

module.exports = (toolbox) => {
  const { print } = toolbox

  toolbox.bar = () => { print.info('Bar!') }
}

This is then accessible in your plugin's commands as toolbox.bar.

Loading a plugin

To load a particular plugin (which has to start with nbx-*), install it to your project using npm install --save-dev nbx-PLUGINNAME, and nbx will pick it up automatically.