mirror of
https://github.com/tj/n.git
synced 2024-11-24 19:46:56 +01:00
Add support for trailing comment in .nvmrc (#820)
This commit is contained in:
parent
1a1b61967b
commit
eea2a55533
2
bin/n
2
bin/n
@ -1147,6 +1147,8 @@ function get_nvmrc_version() {
|
||||
verbose_log "found" "${filepath}"
|
||||
local version
|
||||
<"${filepath}" read -r version
|
||||
# remove trailing comment, after #
|
||||
version="$(echo "${version}" | sed 's/[[:space:]]*#.*//')"
|
||||
verbose_log "read" "${version}"
|
||||
# Translate from nvm aliases
|
||||
case "${version}" in
|
||||
|
@ -68,3 +68,11 @@ function setup() {
|
||||
output="$(n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
|
||||
assert_equal "${output}" "8.11.1"
|
||||
}
|
||||
|
||||
@test "auto .nvmrc, trailing comment" {
|
||||
local TARGET_VERSION="8.10.0"
|
||||
cd "${MY_DIR}"
|
||||
printf "${TARGET_VERSION} # comment" > .nvmrc
|
||||
output="$(n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
|
||||
assert_equal "${output}" "${TARGET_VERSION}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user