run terminal commands in custom atom package












0















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.










share|improve this question

























  • 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
















0















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.










share|improve this question

























  • 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














0












0








0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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












1 Answer
1






active

oldest

votes


















0














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.






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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.






    share|improve this answer




























      0














      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.






      share|improve this answer


























        0












        0








        0







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 27 '18 at 7:26









        idlebergidleberg

        7,20852740




        7,20852740
































            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'