1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-12-30 20:59:13 +00:00

perf(dotnet): fail faster in the dotnet module (#1034)

This commit is contained in:
David Knaack 2020-04-03 18:34:35 +02:00 committed by GitHub
parent b3cc7b4016
commit 55503bb77b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,11 +19,20 @@ const PROJECT_JSON_FILE: &str = "project.json";
/// the current directory:
/// global.json, project.json, *.sln, *.csproj, *.fsproj, *.xproj
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let dotnet_files = get_local_dotnet_files(context).ok()?;
if dotnet_files.is_empty() {
// First check if this is a DotNet Project before doing the O(n)
// check for the version using the JSON files
let is_dotnet_project = context
.try_begin_scan()?
.set_files(&[GLOBAL_JSON_FILE, PROJECT_JSON_FILE])
.set_extensions(&["sln", "csproj", "fsproj", "xproj"])
.is_match();
if !is_dotnet_project {
return None;
}
let dotnet_files = get_local_dotnet_files(context).ok()?;
let mut module = context.new_module("dotnet");
let config = DotnetConfig::try_load(module.config);