justin justin - 4 months ago 8
Node.js Question

How can I do the same sort of thing as git editor spawning in node?

I want to spawn an editor in the middle of a program written in Node.js, let the user edit files in the directory opened in the editor, and return control to the program once the new editor instance is closed.

I would imagine I can do this with child_process.spawnSync.

Are there any example packages I can look at on npm which do this?

Answer

Take a look at another StackOverflow answer: on opening a EDITOR from Node.js and dealing with the TTY.

(Also consider using GIT_EDITOR end variable in addition to just EDITOR :)