How to know that a child process is waiting for input and input data to it in nodejs

for example, npm login command requires entering username , password , email

I start a child process to execute npm login how do I know that the child process is waiting for input and input to it?

Feb.23,2022

is entered in the console, use readline , the code is as follows

Node.jsstdinspawn</a>


const fs = require('fs');

const { spawn } = require('child_process');

var subProcess = spawn('cnpm.cmd', ['login'], { cmd: __dirname });
subProcess.on('error', function() {
    console.log('error');
    console.log(arguments);
});
subProcess.on('close', code => {
    if (code != 0) {
        console.log(`:${code}`);
    } else {
        console.log('');
    }
    process.stdin.end();
});
subProcess.stdin.on('end', () => {
    process.stdout.write('end');
});

subProcess.stdout.on('data', onData);
subProcess.stderr.on('data', onData);
function onData(data) {
    process.stdout.write('-sharp ' + data);
    process.stdin.on('data', input => {
        input = input.toString().trim();
        subProcess.stdin.write(input + '\n');
    });
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b348a5-342d0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b348a5-342d0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?