microsoft / microsoft/TypeScript

Set as executable files that are intended to be binaries

Đang mở
#37,583 13 bình luận 15 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Awaiting More Feedback Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

Search Terms

  • mode
  • binary
  • executable
  • package.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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với luồng tsc tạo src/my-binary.ts thành lib/my-binary.js, sau đó điều tra cách các mode của tệp đầu ra hiện được lựa chọn. Công việc được xem là hoàn tất khi đã định nghĩa và triển khai một quy tắc được hỗ trợ để nhận diện các binary dự kiến, đồng thời xác minh rằng JavaScript được tạo ra có thể thực thi mà không thay đổi hành vi hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
typescript
Lĩnh vực
compilers
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.