diff --git a/.github/config-schema.json b/.github/config-schema.json index 0fb22ec3..bcc6684f 100644 --- a/.github/config-schema.json +++ b/.github/config-schema.json @@ -87,6 +87,7 @@ "default": { "detect_extensions": [], "detect_files": [ + "bun.lock", "bun.lockb", "bunfig.toml" ], @@ -2225,6 +2226,7 @@ }, "detect_files": { "default": [ + "bun.lock", "bun.lockb", "bunfig.toml" ], diff --git a/docs/config/README.md b/docs/config/README.md index 19306559..3a832203 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -618,21 +618,22 @@ symbol = '🦬 ' 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: +- The current directory contains a `bun.lock` file - The current directory contains a `bun.lockb` file - The current directory contains a `bunfig.toml` file ### Options -| Option | Default | Description | -| ------------------- | ------------------------------------ | ------------------------------------------------------------------------- | -| `format` | `'via [$symbol($version )]($style)'` | The format for the module. | -| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | -| `symbol` | `'🥟 '` | A format string representing the symbol of Bun. | -| `detect_extensions` | `[]` | Which extensions should trigger this module. | -| `detect_files` | `['bun.lockb', 'bunfig.toml']` | Which filenames should trigger this module. | -| `detect_folders` | `[]` | Which folders should trigger this module. | -| `style` | `'bold red'` | The style for the module. | -| `disabled` | `false` | Disables the `bun` module. | +| Option | Default | Description | +| ------------------- | ------------------------------------------ | ------------------------------------------------------------------------- | +| `format` | `'via [$symbol($version )]($style)'` | The format for the module. | +| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | +| `symbol` | `'🥟 '` | A format string representing the symbol of Bun. | +| `detect_extensions` | `[]` | Which extensions 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. | +| `style` | `'bold red'` | The style for the module. | +| `disabled` | `false` | Disables the `bun` module. | ### Variables diff --git a/src/configs/bun.rs b/src/configs/bun.rs index db50a50c..736f879c 100644 --- a/src/configs/bun.rs +++ b/src/configs/bun.rs @@ -27,7 +27,7 @@ impl<'a> Default for BunConfig<'a> { style: "bold red", disabled: false, detect_extensions: vec![], - detect_files: vec!["bun.lockb", "bunfig.toml"], + detect_files: vec!["bun.lock", "bun.lockb", "bunfig.toml"], detect_folders: vec![], } } diff --git a/src/modules/bun.rs b/src/modules/bun.rs index b83c5cb2..b4db80be 100644 --- a/src/modules/bun.rs +++ b/src/modules/bun.rs @@ -94,6 +94,16 @@ mod tests { 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] fn no_bun_installed() -> io::Result<()> { let dir = tempfile::tempdir()?; @@ -106,4 +116,17 @@ mod tests { assert_eq!(expected, actual); 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() + } }