diff --git a/docs/config/README.md b/docs/config/README.md index 3e63c2fb..ca96bbc1 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -747,20 +747,20 @@ format = "via [🔰 $version](bold red) " The `deno` module shows you your currently installed version of [Deno](https://deno.land/). By default the module will be shown if any of the following conditions are met: -- The current directory contains a `mod.ts`, `mod.js`, `deps.ts` or `deps.js` file +- The current directory contains a `deno.json`, `deno.jsonc`, `mod.ts`, `mod.js`, `deps.ts` or `deps.js` 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 Deno | -| `detect_extensions` | `[]` | Which extensions should trigger this module. | -| `detect_files` | `["mod.ts", "mod.js", "deps.ts", "deps.js"]` | Which filenames should trigger this module. | -| `detect_folders` | `[]` | Which folders should trigger this module. | -| `style` | `"green bold"` | The style for the module. | -| `disabled` | `false` | Disables the `deno` 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 Deno | +| `detect_extensions` | `[]` | Which extensions should trigger this module. | +| `detect_files` | `["deno.json", "deno.jsonc", "mod.ts", "mod.js", "deps.ts", "deps.js"]` | Which filenames should trigger this module. | +| `detect_folders` | `[]` | Which folders should trigger this module. | +| `style` | `"green bold"` | The style for the module. | +| `disabled` | `false` | Disables the `deno` module. | ### Variables diff --git a/src/configs/deno.rs b/src/configs/deno.rs index cb4cddc5..c7b3e45b 100644 --- a/src/configs/deno.rs +++ b/src/configs/deno.rs @@ -24,7 +24,14 @@ impl<'a> Default for DenoConfig<'a> { style: "green bold", disabled: false, detect_extensions: vec![], - detect_files: vec!["mod.ts", "deps.ts", "mod.js", "deps.js"], + detect_files: vec![ + "deno.json", + "deno.jsonc", + "mod.ts", + "deps.ts", + "mod.js", + "deps.js", + ], detect_folders: vec![], } } diff --git a/src/modules/deno.rs b/src/modules/deno.rs index be19dd54..3ab6cbf4 100644 --- a/src/modules/deno.rs +++ b/src/modules/deno.rs @@ -83,6 +83,26 @@ mod tests { dir.close() } + #[test] + fn folder_with_deno_json() -> io::Result<()> { + let dir = tempfile::tempdir()?; + File::create(dir.path().join("deno.json"))?.sync_all()?; + let actual = ModuleRenderer::new("deno").path(dir.path()).collect(); + let expected = Some(format!("via {}", Color::Green.bold().paint("🦕 v1.8.3 "))); + assert_eq!(expected, actual); + dir.close() + } + + #[test] + fn folder_with_deno_jsonc() -> io::Result<()> { + let dir = tempfile::tempdir()?; + File::create(dir.path().join("deno.jsonc"))?.sync_all()?; + let actual = ModuleRenderer::new("deno").path(dir.path()).collect(); + let expected = Some(format!("via {}", Color::Green.bold().paint("🦕 v1.8.3 "))); + assert_eq!(expected, actual); + dir.close() + } + #[test] fn folder_with_mod_ts() -> io::Result<()> { let dir = tempfile::tempdir()?;