From 47a769cdf85d6f42250fe179e482ca40647bb2d8 Mon Sep 17 00:00:00 2001 From: Thomas O'Donnell Date: Sat, 13 Feb 2021 11:38:47 +0100 Subject: feat(cmake): Configure when the module is shown (#2280) This makes it possible to configure when the cmake module is shown based on the contents of a directory. This should make it possible to be a lot more granular when configuring the module. --- src/modules/cmake.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/modules') diff --git a/src/modules/cmake.rs b/src/modules/cmake.rs index 638b7d727..2d003a977 100644 --- a/src/modules/cmake.rs +++ b/src/modules/cmake.rs @@ -4,21 +4,21 @@ use crate::configs::cmake::CMakeConfig; use crate::formatter::StringFormatter; /// Creates a module with the current CMake version -/// -/// Will display the CMake version if any of the following criteria are met: -/// - The current directory contains a `CMakeLists.txt` or `CMakeCache.txt` pub fn module<'a>(context: &'a Context) -> Option> { + let mut module = context.new_module("cmake"); + let config = CMakeConfig::try_load(module.config); + let is_cmake_project = context .try_begin_scan()? - .set_files(&["CMakeLists.txt", "CMakeCache.txt"]) + .set_files(&config.detect_files) + .set_extensions(&config.detect_extensions) + .set_folders(&config.detect_folders) .is_match(); if !is_cmake_project { return None; } - let mut module = context.new_module("cmake"); - let config = CMakeConfig::try_load(module.config); let parsed = StringFormatter::new(config.format).and_then(|formatter| { formatter .map_meta(|variable, _| match variable { -- cgit v1.2.3