From aaabaa83f341dcd69d5a2b3303e7188fa0428927 Mon Sep 17 00:00:00 2001 From: hustcer Date: Thu, 4 Sep 2025 22:22:56 +0800 Subject: [PATCH] feat: Honor `MOONBIT_INSTALL_VERSION` for installing moon bins --- README.md | 2 +- README.zh-CN.md | 2 +- nu/moonbit.nu | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f6cf532..87c821b 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ In rare circumstances you might get rate limiting errors, if this happens you ca | Name | Type | Description | | ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `version` | `string` | Optional, A valid moonbit tool chain version, such as `0.6.18+8382ed77e`, `latest`, `pre-release`, etc. or even `bleeding`, default to `latest` | +| `version` | `string` | Optional, A valid moonbit tool chain version, such as `0.6.18+8382ed77e`, `latest`, `pre-release`, etc. or even `bleeding`. Defaults to `latest` or the value of `MOONBIT_INSTALL_VERSION` environment variable | | `setup-core` | `bool` | Optional, Set to `true` to download and bundle Moonbit Core, `false` to ignore it, default to `true` | | `core-version` | `string` | Optional, A valid moonbit core version, such as `0.6.18+8382ed77e`, `latest`, `pre-release`, `bleeding` etc. Default to `latest` | diff --git a/README.zh-CN.md b/README.zh-CN.md index c3ea1cf..92a8911 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -36,7 +36,7 @@ steps: | 参数名 | 类型 | 描述 | | ------------ | -------- | --------------------------------------------------------------------------------------------------------------------- | -| `version` | `string` | 可选,合法的 Moonbit 工具链版本,比如: `0.6.18+8382ed77e`, `latest`, `pre-release`, 或者 `bleeding`,默认为 `latest` | +| `version` | `string` | 可选,合法的 Moonbit 工具链版本,比如: `0.6.18+8382ed77e`, `latest`, `pre-release`, 或者 `bleeding`。默认为 `latest` 或环境变量 `MOONBIT_INSTALL_VERSION` 的值 | | `setup-core` | `bool` | 设置为 `true` 则下载并打包 Moonbit Core, `false` 则忽略,默认为 `true` | | `core-version` | `string` | 可选,合法的 Moonbit Core 版本,比如: `0.6.18+8382ed77e`, `latest`,`pre-release` 或者 `bleeding`,默认为 `latest` | diff --git a/nu/moonbit.nu b/nu/moonbit.nu index 689ed79..77e6238 100644 --- a/nu/moonbit.nu +++ b/nu/moonbit.nu @@ -59,10 +59,11 @@ def fetch-core [ version: string ] { # Download moonbit binary files to local export def 'setup moonbit' [ - version: string = 'latest', # The version of moonbit toolchain to setup, and `latest` by default - --setup-core(-c), # Setup moonbit core + version?, # The version of moonbit toolchain to setup, and `latest` by default + --setup-core(-c), # Setup moonbit core --core-version(-V): string = 'latest', # The version of moonbit core to setup, `latest` by default ] { + let version = $version | default $env.MOONBIT_INSTALL_VERSION? | default 'latest' if ($version not-in $VALID_VERSION_TAG) and not (is-semver $version) { print $'(ansi r)Invalid version: ($version)(ansi reset)'; exit 2 }