Plugin
import type { Plugin } from "https://garn.io/ts/v0.0.16/mod.ts";Plugins automatically add one or more fields to your project. You can use
existing plugins to automatically add prepackaged functionality to your Project.
declare them manually yourself.
Here's an example of a simple Plugin and how to use it:
import * as garn from "https://garn.io/ts/v0.0.16/mod.ts";
import * as pkgs from "https://garn.io/ts/v0.0.16/nixpkgs.ts";
const prettier =
(
globPattern: string,
): garn.Plugin<
{ formatCheck: garn.Check; format: garn.Executable },
garn.ProjectHelpers
> =>
(p) =>
p
.withDevTools([pkgs.nodePackages.prettier])
.addCheck("formatCheck", `prettier --check '${globPattern}'`)
.addExecutable("format", `prettier --write '${globPattern}'`);
export const frontend = garn.javascript
.mkNpmProject({
src: ".",
description: "An NPM frontend",
nodeVersion: "18",
})
.add(prettier("src/*.ts"));
type Plugin<Additions, Dependencies = object> = (project: Dependencies & ProjectData) => Additions;