简体   繁体   中英

Atom package command from another package

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?

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

Example:

const target = atom.views.getView(atom.workspace);
const commandName = 'atom-beautify:beautify-language-json';

atom.commands.dispatch(target, commandName);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM