express - How to respond to a command line promt with node.js -
How do I respond to command line prompts with node.js? For example, if I do In addition to this, how do I know that when I want to use it to edit this file (required for phasing my app), deploying on my server, and changing those files (ultimately necessary to deploy the output ). Any help can be rock! You would like to use this to write the command on process.stdin.write ('sudo ls'); The command line will prompt for a password
process.stdin.write ('npm install') is something like this Has been completed?
stdin Instead.
var sys = require ('sys'), exec =' ('child_process'). Exec; // execute 'sudo ls' command with a callback function exec ('sudo ls', function (error, stdout, stderr) {if (error!)} // print output sys.puts (stdout);} and { // handle error}}); To set up
npm you may be better with which you can attach an event listener to run the attachment, you can do the following :
var spawn = is required ('child_process'). Eggs; // run the 'install' argument with the 'NPM' command run npmInstall var npmInstall = spawn ('npm', ['install'], {cwd: process.cwd (), stdio: ' Inherit ')); // Listen to 'Extit' event // which proceeds from npmInstall.on ('Exit', Function (Code, Signal) (if (code === 0) {// Process successfully completed} And {/ handle error}});
Comments
Post a Comment