Search code examples
node.jsvorpal.js

How can all commands be removed


In the command.remove() example I can find and remove one command.

Eg.

const all = vorpal.find('*');
for (var cmd of all) {
  cmd.remove();
}

Is there an official way to remove all commands?


Solution

  • It's simple enough that there doesn't really need to be an API method for it.

    All commands are exposed through vorpal.commands. So:

    vorpal.commands.forEach(function (cmd) {
      cmd.remove();
    });
    

    That should work.