[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
@@ -93,3 +93,13 @@ EXPECTED_PKGS=''
|
||||
touch "${FILE}"
|
||||
|
||||
cleanup
|
||||
|
||||
setup
|
||||
|
||||
printf 'rimraf\r\nobject-inspect@1.0.2\r\n\r\n# commented-package\r\n\r\nstevemao/left-pad\r\n' > "${FILE}"
|
||||
|
||||
DEFAULT_PKGS="$(nvm_get_default_packages)"
|
||||
EXPECTED_PKGS='rimraf object-inspect@1.0.2 stevemao/left-pad'
|
||||
[ "${DEFAULT_PKGS}" = "${EXPECTED_PKGS}" ] || die "6: expected default packages from a CRLF file >${EXPECTED_PKGS}<; got >${DEFAULT_PKGS}<"
|
||||
|
||||
cleanup
|
||||
Reference in new issue
Block a user