how to start a text editor from node.js? -


i'm trying open unix text editor (nano in case) issuing following command in node.js script:

  if (process.argv[2] === 'edit') {     require('child_process').spawn("sudo", ["nano", dbfile], {       stdio: 'inherit'     });     process.exit(); // try block here in order not execute rest of code in file   } 

this opens nano, both text weird , doesn't let me write anything.

i changed bit. added event listener on data on process spawned.

var dbfile = 'lol.js'; var editorspawn = require('child_process').spawn("nano", [dbfile], {   stdio: 'inherit',   detached: true });  editorspawn.on('data', function(data){   process.stdout.pipe(data); }); 

inside of data listener, process.stdout.pipe streaming output of nano terminal.

added own variables , removed sudo giving me errors. should able apply code.


Comments