mirror of
https://github.com/starship/starship.git
synced 2024-12-24 16:18:53 +01:00
fix(nodejs): Check for .nvmrc
(#2626)
* feat(nodejs): Check for `.nvmrc` * Fix test
This commit is contained in:
parent
abe19c712d
commit
aaf1f246d7
@ -1863,6 +1863,7 @@ By default the module will be shown if any of the following conditions are met:
|
||||
|
||||
- The current directory contains a `package.json` file
|
||||
- The current directory contains a `.node-version` file
|
||||
- The current directory contains a `.nvmrc` file
|
||||
- The current directory contains a `node_modules` directory
|
||||
- The current directory contains a file with the `.js`, `.mjs` or `.cjs` extension
|
||||
- The current directory contains a file with the `.ts` extension
|
||||
|
@ -26,7 +26,7 @@ impl<'a> Default for NodejsConfig<'a> {
|
||||
disabled: false,
|
||||
not_capable_style: "bold red",
|
||||
detect_extensions: vec!["js", "mjs", "cjs", "ts"],
|
||||
detect_files: vec!["package.json", ".node-version"],
|
||||
detect_files: vec!["package.json", ".node-version", ".nvmrc"],
|
||||
detect_folders: vec!["node_modules"],
|
||||
}
|
||||
}
|
||||
|
@ -170,6 +170,17 @@ mod tests {
|
||||
dir.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folder_with_nvmrc() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
File::create(dir.path().join(".nvmrc"))?.sync_all()?;
|
||||
|
||||
let actual = ModuleRenderer::new("nodejs").path(dir.path()).collect();
|
||||
let expected = Some(format!("via {}", Color::Green.bold().paint(" v12.0.0 ")));
|
||||
assert_eq!(expected, actual);
|
||||
dir.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folder_with_js_file() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
|
Loading…
Reference in New Issue
Block a user