var standard_input = process.stdin;
// Set input character encoding.
standard_input.setEncoding('utf-8');
// Prompt user to input data in console.
console.log("Please input text in command line.");
// When user input data and click enter key.
standard_input.on('data', function (data) {
// User input exit.
if(data === 'exit\n'){
// Program exit.
console.log("User input complete, program exit.");
process.exit();
}else
{
// Print user input in console.
console.log('User Input Data : ' + data);
}
});
위 코드 실행하고 cmd창에서 exit하고 엔터 쳐도 프로그램 종료가 안되는데 이유를 도무지 모르겠음
exit하고 엔터치면 User Input Data : exit 이렇게만 게속 나옴. 그리고 if문 괄호안에 exit 뒤에 n이아니고 \n임
해당 댓글은 삭제되었습니다.
그 방법말고 코드 로직처럼 exit 입력하면 종료대야되는데 안되서