microsoft / microsoft/TypeScript
Set as executable files that are intended to be binaries
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Search Terms
modebinaryexecutablepackage.json bin
Suggestion
Currently, the TypeScript compiler always generates files with the 644 mode. But some files are meant to be executable: they may start with #!/usr/bin/env node; they may be marked as bin in package.json; they may have an executable mode set on the .ts source; and so forth.
It’d be great if the TypeScript compiler would take any of the hints I mentioned above, figure that the file should be executable, and create the .js as so.
At least the TypeScript compiler doesn’t change the mode of existing .js files when overwriting them, so I can chmod once, and as long as never delete the file, it’ll have the right mode.
Use Cases
This is mostly for development and running the binary from the command-line directly. Once you install the package, npm puts the binary in the node_modules/.bin folder, npx picks it up, and all is good.
Examples
You’re working on a project that should provide a binary: src/my-binary.ts. You do one of the things I mentioned to indicate that the file should be executable. You run tsc, and the generated file at lib/my-binary.js is marked as +x. Then you can call the binary with lib/my-binary.js from the command-line and it works.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
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 con il flusso di tsc che emette src/my-binary.ts come lib/my-binary.js, quindi analizza come vengono attualmente scelti i mode dei file di output. Il lavoro è completato quando viene definita e implementata una regola supportata per riconoscere i binari destinati all’esecuzione e viene verificato che il JavaScript generato sia eseguibile senza modificare il comportamento esistente.
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
- 35/100