run terminal commands in custom atom package
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
.
javascript shell atom-editor
add a comment |
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
.
javascript shell atom-editor
Do you want to run a command or do you want a command prompt to open and then run the command?
– idleberg
Nov 26 '18 at 9:16
Either one, the ultimate goal to run the java compilation command, so if it is possible to run a command without having to make the command prompt visible, that is preferable.
– john doe
Nov 27 '18 at 2:58
add a comment |
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
.
javascript shell atom-editor
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
.
javascript shell atom-editor
javascript shell atom-editor
edited Nov 26 '18 at 4:33
john doe
asked Nov 25 '18 at 21:08
john doejohn doe
14
14
Do you want to run a command or do you want a command prompt to open and then run the command?
– idleberg
Nov 26 '18 at 9:16
Either one, the ultimate goal to run the java compilation command, so if it is possible to run a command without having to make the command prompt visible, that is preferable.
– john doe
Nov 27 '18 at 2:58
add a comment |
Do you want to run a command or do you want a command prompt to open and then run the command?
– idleberg
Nov 26 '18 at 9:16
Either one, the ultimate goal to run the java compilation command, so if it is possible to run a command without having to make the command prompt visible, that is preferable.
– john doe
Nov 27 '18 at 2:58
Do you want to run a command or do you want a command prompt to open and then run the command?
– idleberg
Nov 26 '18 at 9:16
Do you want to run a command or do you want a command prompt to open and then run the command?
– idleberg
Nov 26 '18 at 9:16
Either one, the ultimate goal to run the java compilation command, so if it is possible to run a command without having to make the command prompt visible, that is preferable.
– john doe
Nov 27 '18 at 2:58
Either one, the ultimate goal to run the java compilation command, so if it is possible to run a command without having to make the command prompt visible, that is preferable.
– john doe
Nov 27 '18 at 2:58
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53472008%2frun-terminal-commands-in-custom-atom-package%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 27 '18 at 7:26
idlebergidleberg
7,20852740
7,20852740
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53472008%2frun-terminal-commands-in-custom-atom-package%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you want to run a command or do you want a command prompt to open and then run the command?
– idleberg
Nov 26 '18 at 9:16
Either one, the ultimate goal to run the java compilation command, so if it is possible to run a command without having to make the command prompt visible, that is preferable.
– john doe
Nov 27 '18 at 2:58