Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

node-version as fallback of node-version-file

未关闭
#939 11 条评论 6 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
领域
ci-cd

调研方向

从 src/main.ts 的第 85-95 行开始,跟踪 node-version 和 node-version-file 的选择方式,然后阅读 src/util.ts 的第 8-12 行,了解文件查找行为。完成的标准是:现有文件具有优先级;当同时提供两个输入时,如果文件缺失,则回退到 node-version,且不会导致 pipeline 崩溃。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
5k
派生
1.7k
平均合并
5 天 4 小时
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

actions/setup-node 的其他 Issue

查看 actions/setup-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。