[feature request] Indent output of nested `npm` commands

Aperta
#155 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
28/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, node.js
Ambito
cli

Direzione di ricerca

Start by reading Node.js tty and readline documentation, then trace how run-script launches nested npm commands and handles inherited output. The feature is done when direct and indirect nested commands visibly indent their stdout and stderr, preserve parent-child boundaries, and account for resize and non-TTY behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Needs Triage
Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

When running nested npm commands like implicit pre and post scripts (pretest, prepack, preinstall...), they are run on new spawned processes, with the only reference to where they start by the process banner, but there's no indication of where they end or their relationship, since output is flat.

Expected Behavior

I would like that when a npm command is exec as direct or indirect result of a previous npm command, that its output gets indented, so it's easier to see where they start and end and who's its parent npm process. To do it, we would need to do:

  1. detect we are running as a nested npm command, if not proceed as usual.
  2. use https://nodejs.org/api/tty.html or https://nodejs.org/api/readline.html to create a virtual TTY where to run the command, instead of using inherit. Also handle the resize event, and maybe mimic someway the commands they are not running on a TTY if the parent process doesn't does it.
  3. process the output to the stdout and stderr of the virtual TTY, and indent it for each new newline that arrives
Steps To Reproduce

No response

Environment
  • npm: 9.6.7
  • Node: v20.3.1
  • OS: Ubuntu Linux 23.04
  • platform: x86_64
Lingua principale
JavaScript
Stelle
60
Fork
29
Merge medio
2g 23h
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di npm/run-script

Tutte le issue di npm/run-script

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.