Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
How to answer a CLI question using exec from child_process in NodeJs

I have a problem where I run a script in NodeJs, in this script I have an exec function which calls a CLI program, that CLI program requires two other answers after that command, but I don't know how I can answer this when I exec this from child_process so the command will be forever waiting for these answers.

Here is an example, just keep in mind where I have the command npm init, it will be the CLI program I am using instead, I know with npm I could pass some flag like -y and it will work for the answers, but I don't have this feature in the CLI program:

import { exec } from 'child_process';
import { promisify } from 'util';

const execFunction = promisify(exec);

const { stdout } = await execFunction(`npm init`);

console.log('stdout', stdout);
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda