Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
php-cs-fixer: add configFile option (hercules-ci#172)
Browse files Browse the repository at this point in the history
* php-cs-fixer: add configFile option

* update php-cs-fixer formatter example
  • Loading branch information
RTUnreal committed Mar 27, 2024
1 parent 7ee5aaa commit c2172ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/formatter-php-cs-fixer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
command = "php-cs-fixer"
excludes = []
includes = ["*.php"]
options = ["fix"]
options = ["fix", "--config", "./.php-cs-fixer.php"]
9 changes: 8 additions & 1 deletion programs/php-cs-fixer.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
{ lib, pkgs, config, ... }:
let
inherit (lib) types;
cfg = config.programs.php-cs-fixer;
in
{
options.programs.php-cs-fixer = {
enable = lib.mkEnableOption "php-cs-fixer";
package = lib.mkPackageOption pkgs.phpPackages "php-cs-fixer" { };
configFile = lib.mkOption {
description = "Path to php-cs-fixer config file.";
type = types.oneOf [ types.str types.path ];
default = "./.php-cs-fixer.php";
example = "./.php-cs-fixer.dist.php";
};
};

config = lib.mkIf cfg.enable {
settings.formatter.php-cs-fixer = {
command = "${cfg.package}/bin/php-cs-fixer";
options = [ "fix" ];
options = [ "fix" "--config" "${cfg.configFile}" ];
includes = [ "*.php" ];
};
};
Expand Down

0 comments on commit c2172ef

Please sign in to comment.