【发布时间】:2021-07-30 22:45:41
【问题描述】:
我正在编写一个 bash 脚本来批量更新和测试包。但是,我希望脚本不要跳转到最新版本,只要下一个主要版本存在并通过测试。
我正在研究与此类似的东西(为简洁起见,将较长的代码段简化为伪代码)
#!/bin/bash
# Assign package name to $packageName
# START MAIN LOOP
# Start code that does a preliminary test
...
# End code that does preliminary test
# Assign current package version to $current
npm install $packagename@#[next?]
# # The above line is the one I can't figure out.
# Say, for example, $current is 3.4.7. and
# $packagename@latest is 5.2.3. This should
# update to 4.0.0, but if latest is 3.5.8, it would update
# to 3.5.8, but then not update if latest is 3.4.7
# Do post tests
# # If fails post tests
# alert user to breaking version
npm install $packagename@$current # revert to previous version
# # If succeeds post tests, check if now at @latest
# # # If not at @latest, repeat MAIN LOOP
# # # If at @latest, exit 0.
【问题讨论】:
-
@markp-fuso 这不是掩饰。关键部分是我不知道该怎么做的部分。我不想识别各种方案,我只想选择下一个主要版本而不考虑方案,因为 npm 支持主要/次要版本。
标签: bash npm package-managers