diff options
author | Shu Kutsuzawa <cappyzawa@gmail.com> | 2021-02-22 03:52:19 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-21 19:52:19 +0100 |
commit | efb82454f2ce63a2e7af07888421bd88271432f1 (patch) | |
tree | 5f8695076b47ddb941a508c554ba0bccc5f74ef0 /src/modules | |
parent | 51f752f6b0ddb616a03923bf0de0adac2f565beb (diff) |
feat(php): Configure when the module is shown (#2356)
This makes it possible to configure when the php 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.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/php.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/modules/php.rs b/src/modules/php.rs index f85cbd21e..3152c0c18 100644 --- a/src/modules/php.rs +++ b/src/modules/php.rs @@ -4,24 +4,20 @@ use crate::configs::php::PhpConfig; use crate::formatter::StringFormatter; /// Creates a module with the current PHP version -/// -/// Will display the PHP version if any of the following criteria are met: -/// - Current directory contains a `.php` file -/// - Current directory contains a `composer.json` or `.php-version` file pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { + let mut module = context.new_module("php"); + let config: PhpConfig = PhpConfig::try_load(module.config); let is_php_project = context .try_begin_scan()? - .set_files(&["composer.json", ".php-version"]) - .set_extensions(&["php"]) + .set_files(&config.detect_files) + .set_folders(&config.detect_folders) + .set_extensions(&config.detect_extensions) .is_match(); if !is_php_project { return None; } - let mut module = context.new_module("php"); - let config: PhpConfig = PhpConfig::try_load(module.config); - let parsed = StringFormatter::new(config.format).and_then(|formatter| { formatter .map_meta(|variable, _| match variable { |