Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

node-version as fallback of node-version-file

Đang mở
#939 11 bình luận 6 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 8 ngày

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

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
node.js, typescript
Lĩnh vực
ci-cd

Hướng nghiên cứu

Bắt đầu tại src/main.ts ở các dòng 85-95 để theo dõi cách node-version và node-version-file được chọn, sau đó đọc src/util.ts ở các dòng 8-12 để kiểm tra hành vi tra cứu tệp. Được xem là hoàn tất khi tệp hiện có được ưu tiên, còn tệp bị thiếu sẽ chuyển sang node-version khi cả hai đầu vào đều được cung cấp mà không làm pipeline bị crash.

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

Mô tả

feature request
Description

Currently the behavior is that node-version is preferred rather than node-version-file if both are provided.

https://github.com/actions/setup-node/blob/d86ebcd40b3cb50b156bfa44dd277faf38282d12/src/main.ts#L85-L95

I would like to propose the opposite since node-version is actually hardcoded in the action parameters, but the file is not guaranteed to be there.

https://github.com/actions/setup-node/blob/d86ebcd40b3cb50b156bfa44dd277faf38282d12/src/util.ts#L8-L12

Currently, scenarios resolved as following:

with:
  node-version: 8 # nothing to see here
with:
  node-version-file: fileExists.json # all good
with:
  node-version-file: fileDoesNotExists.json # throws error and crashes the pipeline
with:
  node-version: 8
  node-version-file: fileExists.json # ignored, picked version is 8
with:
  node-version: 8
  node-version-file: fileDoesNotExists.json # ignored, picked version is 8

What I'm requesting for is a change in the 2 lasts scenarios:

with:
  node-version: 8
  node-version-file: fileExists.json # has priority, so it's picked
with:
  node-version: 8
  node-version-file: fileDoesNotExists.json # does not throw and picks version 8 instead
Justification

This is just a nicer API, i think. it does not remove the case of conscious crash of the pipeline if no node-version is given, but it does nicely propose a fail-safe for people interested.

Note

We could also have another parameter such as node-version-fallback-if-file-not-found but it'd just increase the complexity of the api.

Are you willing to submit a PR?

Yes, i'm ok with that.

Ngôn ngữ chính
TypeScript
Star
5k
Fork
1.7k
Merge trung bình
2 ngày 11 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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.

Issue khác của actions/setup-node

Tất cả issue của actions/setup-node

Issue tương tự

Thêm issue về TypeScript

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.