depot/third_party/nixpkgs/pkgs/by-name/bl/blade-formatter/package.nix
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

67 lines
1.5 KiB
Nix

{
lib,
buildNpmPackage,
fetchFromGitHub,
testers,
writeText,
runCommand,
blade-formatter,
nodejs,
}:
buildNpmPackage rec {
pname = "blade-formatter";
version = "1.41.1";
src = fetchFromGitHub {
owner = "shufo";
repo = "blade-formatter";
rev = "v${version}";
hash = "sha256-iaWpIa+H+ocAXGc042PfmCu9UcJZeso9ripWB2/1oTs=";
};
postPatch = ''
cp ${./package-lock.json} ./package-lock.json
'';
npmDepsHash = "sha256-wEz0DTbg+Fdmsf0Qyeu9QS+I8gkPJeaJC/3HuP913og=";
passthru = {
updateScript = ./update.sh;
tests = {
version = testers.testVersion {
package = blade-formatter;
command = "blade-formatter --version";
};
simple = testers.testEqualContents {
assertion = "blade-formatter formats a basic blade file";
expected = writeText "expected" ''
@if (true)
Hello world!
@endif
'';
actual =
runCommand "actual"
{
nativeBuildInputs = [ blade-formatter ];
base = writeText "base" ''
@if( true ) Hello world! @endif
'';
}
''
blade-formatter $base > $out
'';
};
};
};
meta = {
description = "Laravel Blade template formatter";
homepage = "https://github.com/shufo/blade-formatter";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ lelgenio ];
mainProgram = "blade-formatter";
inherit (nodejs.meta) platforms;
};
}