Pana / nrm

NPM registry manager, fast switch between different registries: npm, cnpm, nj, taobao
MIT License
2.81k stars 250 forks source link

fix: remove unnecessary if condition #108

Closed CaptainOfPhB closed 2 years ago

CaptainOfPhB commented 3 years ago

Problem nrm ls and nrm current can not display the current registry.

Bug hasOwnProperty(customRegistries, name) is always false after nrm use taobao(for example), so the statement registry[FIELD_IS_CURRENT] = true; can not be executed forever.

Description name in allRegistries is already judged in L186, allRegistry include customRegistry and registries, so the if condition in L211 is unnecessary.

Fix: #101 Fix: #109 Fix: #110

CaptainOfPhB commented 3 years ago

@i5ting

i5ting commented 3 years ago

@CaptainOfPhB 补一下测试用例

CaptainOfPhB commented 3 years ago

@CaptainOfPhB 补一下测试用例

@i5ting 这个库没有单测呀😂

xiaoyu-666 commented 3 years ago

呃,我没看到这次提交

i5ting commented 3 years ago

@CaptainOfPhB 加一个uvu或tap做测试吧,撸起来

xiaoyu-666 commented 3 years ago

@CaptainOfPhB 加一个uvu或tap做测试吧,撸起来 如果这个if条件判断去掉后, 还有一个问题也能复发这个没有星号的问题,就是本机是windows系统,安装了wsl子系统,两个系统都安装了npm,wsl子系统npm的/hone/用户名/.npmrc配置文件会被本机windows系统中C:\Users\用户名\.npmrc的配置文件覆盖,这时候wsl子系统使用nrm use taobao都会失效,只要删除本机windows系统中npm的配置文件即可恢复正常