mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 19:51:17 +00:00
textlint: add test utility
This commit is contained in:
parent
cd59be301d
commit
68c7f8e5ab
|
@ -58,6 +58,38 @@ buildNpmPackage rec {
|
|||
makeWrapper ${textlint}/bin/textlint $out/bin/textlint \
|
||||
--set NODE_PATH ${lib.makeSearchPath "lib/node_modules" ps}
|
||||
'';
|
||||
|
||||
testPackages =
|
||||
{
|
||||
rule,
|
||||
testFile,
|
||||
pname ? rule.pname,
|
||||
plugin ? null,
|
||||
}:
|
||||
let
|
||||
ruleName = lib.removePrefix "textlint-rule-" rule.pname;
|
||||
isPreset = lib.hasPrefix "preset-" ruleName;
|
||||
ruleName' = lib.removePrefix "preset-" ruleName;
|
||||
pluginName = lib.removePrefix "textlint-plugin-" plugin.pname;
|
||||
args =
|
||||
"${testFile} ${if isPreset then "--preset" else "--rule"} ${ruleName'}"
|
||||
+ lib.optionalString (plugin != null) " --plugin ${pluginName}";
|
||||
in
|
||||
{
|
||||
"${pname}-test" =
|
||||
runCommand "${pname}-test"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
(textlint.withPackages [
|
||||
rule
|
||||
plugin
|
||||
])
|
||||
];
|
||||
}
|
||||
''
|
||||
grep ${ruleName'} <(textlint ${args}) > $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
|
Loading…
Reference in a new issue