nodejs | 명령 행 인 자 를 가 져 오고 cli 스 크 립 트 에 인 자 를 전달 합 니 다.
791 단어 node
import { createInterface } from 'readline'
export const getUserInput = (question: string): Promise =>
new Promise(resolve => {
const terminal = createInterface({
input: process.stdin,
output: process.stdout
})
terminal.question(question, answer => {
terminal.close()
resolve(answer.trim())
})
})
// getUserInput('input: ').then(res => console.log(res))
node ./index.js param 스 크 립 트 에서 param 가 져 오기
process.argv // string[]
최근 에 ts 로 cli 도 구 를 썼 습 니 다. 관심 있 는 것 은 시도 해 보 세 요.
npm install saber-tsmod -g
cli 프로그램 소스 코드:
Saber2pr/saber-tsmod
https://github.com/Saber2pr/saber-tsmod
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Express.js에서 오류를 처리하는 간단한 방법Express에서 오류를 처리하는 여러 가지 방법이 있습니다. 이를 수행하는 일반적인 방법은 기본 익스프레스 미들웨어를 사용하는 것입니다. 또 다른 방법은 컨트롤러 내부의 오류를 처리하는 것입니다. 이러한 처리 방식...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.