I am currently creating an atom package which runs commands on the windows command prompt not the atom command prompt. So far, I only have the code:
if (editor = atom.workspace.getActiveTextEditor()){
let editor = atom.workspace.getActiveTextEditor();
let file = editor.buffer.file;
let path = file.path;
editor.save();
editor.insertText(path);
}
I do not know how to spawn a command window or how to run a command. All that code does is check if the user is in a text window and then for testing purposes inserts the path into the text window. Eventually, I am going to need to run cd path
.
To execute a program, you can use the with child_process
module that's bundled with Node (Atom has its own wrapper for it, see BufferedProcess
)
Example:
// Somewhere in your header
const { spawn } = require('child_process');
// Where you need to execute the Java compiler
const javac = spawn('javac', [path], {stdio: inherit});
For debugging purposes, you probably want to use something like console-panel to print messages.
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.