Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

node-version as fallback of node-version-file

Abierto
#939 11 comentarios 6 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
node.js, typescript
Área
ci-cd

Línea de trabajo

Comienza en src/main.ts, en las líneas 85-95, para seguir cómo se seleccionan node-version y node-version-file; después, lee src/util.ts, en las líneas 8-12, para comprobar el comportamiento de búsqueda de archivos. Se considera completado cuando un archivo existente tiene prioridad, mientras que un archivo inexistente recurre a node-version cuando se proporcionan ambas entradas, sin que la pipeline se bloquee.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
5k
Forks
1.7k
Merge medio
2 d 11 h
PR fusionados (30 d)
3

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de actions/setup-node

Todos los issues de actions/setup-node

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.