diff options
author | Kid <44045911+kidonng@users.noreply.github.com> | 2021-04-23 00:08:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-22 12:08:12 -0400 |
commit | aaf1f246d7ee079da3a51707cc3c8adad8874be3 (patch) | |
tree | 742aa514e9f56ebaebb98f56a64091e9d076ced0 /src | |
parent | abe19c712d13bbcd14c918c96b2c7af24d8a37dd (diff) |
fix(nodejs): Check for `.nvmrc` (#2626)
* feat(nodejs): Check for `.nvmrc`
* Fix test
Diffstat (limited to 'src')
-rw-r--r-- | src/configs/nodejs.rs | 2 | ||||
-rw-r--r-- | src/modules/nodejs.rs | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/configs/nodejs.rs b/src/configs/nodejs.rs index 6d905069f..fbafc7f50 100644 --- a/src/configs/nodejs.rs +++ b/src/configs/nodejs.rs @@ -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"], } } diff --git a/src/modules/nodejs.rs b/src/modules/nodejs.rs index 1bcfbdda3..b48e5d83c 100644 --- a/src/modules/nodejs.rs +++ b/src/modules/nodejs.rs @@ -171,6 +171,17 @@ mod tests { } #[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()?; File::create(dir.path().join("index.js"))?.sync_all()?; |