mirror of
https://github.com/Llewellynvdm/starship.git
synced 2025-01-28 17:48:25 +00:00
feat(bun): Detect bun using new text-format lockfile (#6441)
* Support bun text-format lockfile Bun version 1.1.39 introduced a new plaintext lockfile. Currently it is opt-in only, but it will become the default in bun version 1.2. * update docs * update config schema * update tests
This commit is contained in:
parent
2922ee78d2
commit
2df521c69b
2
.github/config-schema.json
vendored
2
.github/config-schema.json
vendored
@ -87,6 +87,7 @@
|
|||||||
"default": {
|
"default": {
|
||||||
"detect_extensions": [],
|
"detect_extensions": [],
|
||||||
"detect_files": [
|
"detect_files": [
|
||||||
|
"bun.lock",
|
||||||
"bun.lockb",
|
"bun.lockb",
|
||||||
"bunfig.toml"
|
"bunfig.toml"
|
||||||
],
|
],
|
||||||
@ -2225,6 +2226,7 @@
|
|||||||
},
|
},
|
||||||
"detect_files": {
|
"detect_files": {
|
||||||
"default": [
|
"default": [
|
||||||
|
"bun.lock",
|
||||||
"bun.lockb",
|
"bun.lockb",
|
||||||
"bunfig.toml"
|
"bunfig.toml"
|
||||||
],
|
],
|
||||||
|
@ -618,21 +618,22 @@ symbol = '🦬 '
|
|||||||
The `bun` module shows the currently installed version of the [bun](https://bun.sh) JavaScript runtime.
|
The `bun` module shows the currently installed version of the [bun](https://bun.sh) JavaScript runtime.
|
||||||
By default the module will be shown if any of the following conditions are met:
|
By default the module will be shown if any of the following conditions are met:
|
||||||
|
|
||||||
|
- The current directory contains a `bun.lock` file
|
||||||
- The current directory contains a `bun.lockb` file
|
- The current directory contains a `bun.lockb` file
|
||||||
- The current directory contains a `bunfig.toml` file
|
- The current directory contains a `bunfig.toml` file
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Option | Default | Description |
|
| Option | Default | Description |
|
||||||
| ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
|
| ------------------- | ------------------------------------------ | ------------------------------------------------------------------------- |
|
||||||
| `format` | `'via [$symbol($version )]($style)'` | The format for the module. |
|
| `format` | `'via [$symbol($version )]($style)'` | The format for the module. |
|
||||||
| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
|
| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
|
||||||
| `symbol` | `'🥟 '` | A format string representing the symbol of Bun. |
|
| `symbol` | `'🥟 '` | A format string representing the symbol of Bun. |
|
||||||
| `detect_extensions` | `[]` | Which extensions should trigger this module. |
|
| `detect_extensions` | `[]` | Which extensions should trigger this module. |
|
||||||
| `detect_files` | `['bun.lockb', 'bunfig.toml']` | Which filenames should trigger this module. |
|
| `detect_files` | `['bun.lock', 'bun.lockb', 'bunfig.toml']` | Which filenames should trigger this module. |
|
||||||
| `detect_folders` | `[]` | Which folders should trigger this module. |
|
| `detect_folders` | `[]` | Which folders should trigger this module. |
|
||||||
| `style` | `'bold red'` | The style for the module. |
|
| `style` | `'bold red'` | The style for the module. |
|
||||||
| `disabled` | `false` | Disables the `bun` module. |
|
| `disabled` | `false` | Disables the `bun` module. |
|
||||||
|
|
||||||
### Variables
|
### Variables
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ impl<'a> Default for BunConfig<'a> {
|
|||||||
style: "bold red",
|
style: "bold red",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
detect_extensions: vec![],
|
detect_extensions: vec![],
|
||||||
detect_files: vec!["bun.lockb", "bunfig.toml"],
|
detect_files: vec!["bun.lock", "bun.lockb", "bunfig.toml"],
|
||||||
detect_folders: vec![],
|
detect_folders: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,16 @@ mod tests {
|
|||||||
dir.close()
|
dir.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn folder_with_bun_file_text_lockfile() -> io::Result<()> {
|
||||||
|
let dir = tempfile::tempdir()?;
|
||||||
|
File::create(dir.path().join("bun.lock"))?.sync_all()?;
|
||||||
|
let actual = ModuleRenderer::new("bun").path(dir.path()).collect();
|
||||||
|
let expected = Some(format!("via {}", Color::Red.bold().paint("🥟 v0.1.4 ")));
|
||||||
|
assert_eq!(expected, actual);
|
||||||
|
dir.close()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_bun_installed() -> io::Result<()> {
|
fn no_bun_installed() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
@ -106,4 +116,17 @@ mod tests {
|
|||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
dir.close()
|
dir.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn no_bun_installed_text_lockfile() -> io::Result<()> {
|
||||||
|
let dir = tempfile::tempdir()?;
|
||||||
|
File::create(dir.path().join("bun.lock"))?.sync_all()?;
|
||||||
|
let actual = ModuleRenderer::new("bun")
|
||||||
|
.path(dir.path())
|
||||||
|
.cmd("bun --version", None)
|
||||||
|
.collect();
|
||||||
|
let expected = Some(format!("via {}", Color::Red.bold().paint("🥟 ")));
|
||||||
|
assert_eq!(expected, actual);
|
||||||
|
dir.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user