microsoft / microsoft/TypeScript
hook into `tsc --watch` using stdout -- the unix way
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
This is a feature request.
I would like to launch tsc -w and then read from stdout to know when tsc -w has started and completed a build. Like so:
const cp = require('child_process');
const k = cp.spawn('bash');
setImmediate(function(){
k.stdin.end(`\n tsc --watch --project x \n`);
});
let stdout = '';
k.stdout.on('data', function(d){
stdout += String(d);
if(/foobar/.test(stdout)){
makeMyDay();
}
});
Right now, tsc --watch outputs stdout that is mostly just human readable, and doesn't provide very useful information:
1:33:44 PM - File change detected. Starting incremental compilation...
../suman-types/dts/it.d.ts(6,18): error TS2430: Interface 'ITestDataObj' incorrectly extends interface 'ITestOrHookBase'.
Property 'cb' is optional in type 'ITestDataObj' but required in type 'ITestOrHookBase'.
../suman-types/dts/test-suite.d.ts(13,23): error TS2503: Cannot find namespace 'Chai'.
1:33:44 PM - Compilation complete. Watching for file changes.
Proposal:
tsc --watch should have a new flag, that tells tsc --watch to output machine readable data to stdout, instead of human readable data. For example:
tsc --watch --machine-stdio
Using this new flag, no existing users will be affected.
Ideally, output JSON to stdout, something like this upon a file change:
const data = {source: '@tscwatch', event: 'file_change', srcfilePath: filePath, willTranspile: true/false, destinationFilePath: null / destinationFilePath};
console.log(JSON.stringify(data);
then after transpilation finishes, write something like this to stdout:
const data = {source: '@tscwatch', event: 'compilation_complete', errors: null / errors:[]};
console.log(JSON.stringify(data));
if it's behind a flag (--machine-stdio) then it won't affect any current users, so should be safe.
I need a truly unique field value like '@tscwatch' so that I know that the JSON is coming from a certain process. In general, it's possible to be parsing more than one JSON stream from a process, so having a unique field in each JSON object makes this better.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando il percorso del comando tsc --watch e i messaggi stdout esistenti per le modifiche ai file, il completamento della compilazione e gli errori. Determina lo schema degli eventi leggibile dalle macchine e il comportamento del flag, quindi verifica che --machine-stdio emetta eventi JSON identificabili senza modificare l'output predefinito leggibile dagli esseri umani.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 28/100