[Fix] nvm_get_default_packages: ignore CRLF line endings
A `default-packages` file saved with Windows line endings left a carriage return on every package name, and turned each blank line into a lone `\r` entry, so `npm install -g` was given `rimraf\r` and failed. Strip a trailing `\r` from each line before parsing it, like `.nvmrc` parsing already tolerates. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Wei-Lun Li <b84330808@gmail.com>
This commit is contained in:
1 parent
edde7ce995
commit
84b176d46d
3 files changed
+21
No files matched your search
@@ -6600,6 +6600,7 @@ nvm_get_default_packages() {
|
||||
NVM_DEFAULT_PACKAGE_FILE="${NVM_DIR}/default-packages"
|
||||
if [ -f "${NVM_DEFAULT_PACKAGE_FILE}" ]; then
|
||||
command awk '
|
||||
{ sub(/\r$/, "") } # Strip CRLF line endings
|
||||
/^[ \t]*#/ { next } # Skip lines that begin with #
|
||||
/^[ \t]*$/ { next } # Skip empty lines
|
||||
/[ \t]/ && !/^[ \t]*#/ {
|
||||
|
||||
Reference in new issue
Block a user