Closed Wxh16144 closed 2 years ago
What's the reason the projects don't have a lockfile? ni
expects projects to have lockfiles. .nirc
is aim for global configurations like .zshrc
, you don't expect to have .zshrc
in every directory that changes zsh's behavior when you cd into some folder right?
嗯嗯,非常感谢你的回复,赞同你说的,就像 .zshrc
配置文件一样,本身就只是一个全局配置。
如果我真的要使用这个功能,在不去开源仓库提交 PR 的情况下,也只有方案2可以满足我个人特殊需求。
另外据 NodJS 官方文档中所说的 packageManager
还处于实验性阶段
对于我这种不太合理的需求,且属于小众需求,我认为发一个 @wuxh/ni
私人包即可。感谢大佬的包,站在巨人的肩膀上😂
Sorry to continue this discussion in a closed issue. For this issue, I have implemented a solution myself and it has been stable on my computer for a while, I think it works well, but I don't want to lose the upstream repository updates, if I can I will organize the code and submit a PR, I hope the author can reconsider whether to adopt it. Please forgive me if I am disturbing you!
https://github.com/Wxh16144/ni/commit/017dbbb9390c28497eb93d4848ae0acb0781c892
有这么一个场景,假设有一个文件目录为这样:
我希望在
react-project
目录下使用yarn
, 在vue-project
目录中使用pnpm
;这个时候我有以下几种方案:
"packageManager": "yarn@1.22.0"
;NI_CONFIG_FILE
环境变量,指定.nirc
文件路径;上述方案的一些顾虑:
方案1: 如果是三方开源项目,需要手动去添加记录,产生不必要的 git 变更。 方案2: 可能需写一些 shell 脚本来支持目录变更后修改环境变量或者覆盖
.nirc
文件内容,如借助.zshrc
的 hooks 方案3: 如果实现则会存在一个问题是配置文件混乱,使用者不知道执行命令后使用的是那个包管理器,当其实可以丰富一下帮助文档,比如ni "?"
目前只是一个 debugger 功能,但可以在这个上面输出更多的内容, config 信息等等等本次功能请求:
如上树形目录图,在没有明确包管理器时,递归向父目录查找配置文件。