Atom package command from another package

Viewed 62

Let's say in my custom Atom package I insert a JSON string into a file. After that, I'd like to run the beautify-language-json from atom-beautify package automatically.

How can I launch this command from my package?

1 Answers

As described in the API documentation, you can use the dispatch() method for that.

Example:

// Example - you *might* want to use a different target
const target = atom.views.getView(atom.workspace);
const commandName = 'atom-beautify:beautify-language-json';

atom.commands.dispatch(target, commandName);
Related