Nov 8, 2023Sönke Hahn

garn version v0.0.15

Release announcement for garn version v0.0.15

Today we released version v0.0.15 of Garn and the accompanying typescript library.

How to get itshare

If you don't have Garn installed you can follow our installation instructions. If you already have Garn installed, then follow our updating guide.

New featuresshare

It's a small release with the following additional user-facing features:

Added a --version flagshare

Added golang version 1.21share

Simplify declaring Checks and Executablesshare

We added simpler overloads to the functions Project.addCheck, Project.addExecutable, Project.check, Project.shell, etc. in the typescript library.

So for example a Check definition used to look like this:

import * as garn from "https://garn.io/ts/v0.0.15/mod.ts";

export const myProject = garn.javascript
  .mkNpmProject({
    description: "my cool project",
    nodeVersion: "18",
    src: ".",
  })
  .addCheck("no todos allowed")`! grep -r TODO src`;

That syntax in the last line with the backticks after the function call to addCheck is valid, but unusual. We designed the API like this to allow to reference packages from nixpkgs and splice them into the script snippets, for example like this:

import * as garn from "https://garn.io/ts/v0.0.15/mod.ts";
import * as pkgs from "https://garn.io/ts/v0.0.15/nixpkgs.ts";

export const myProject = garn.javascript
  .mkNpmProject({
    description: "my cool project",
    nodeVersion: "18",
    src: ".",
  })
  .addCheck("no todos allowed")`! ${pkgs.ripgrep}/bin/rg TODO src`;

Notice that just by splicing in pkgs.ripgrep in that script snippet, you would declare a dependency of that check on ripgrep, so Garn would automatically install ripgrep when running this check. That felt very fancy and cool, and it's also sometimes needed, but it's also much less common than we thought. So now you can just write this instead:

import * as garn from "https://garn.io/ts/v0.0.15/mod.ts";
import * as pkgs from "https://garn.io/ts/v0.0.15/nixpkgs.ts";

export const myProject = garn.javascript
  .mkNpmProject({
    description: "my cool project",
    nodeVersion: "18",
    src: ".",
  })
  .withDevTools([pkgs.ripgrep])
  .addCheck("no todos allowed", "! rg TODO src");

The old syntax still works, in case you want to splice in packages. (Or in case you want to feel fancy and cool.)

Better handling of non-zero exit codes of spawned child processesshare

Consider a failing Executable like this:

import * as garn from "https://garn.io/ts/v0.0.15/mod.ts";

export const foo = garn.shell("echo some error message ; exit 23");

In version v0.0.15 garn run foo now:

  • exits with exit code 23, and
  • doesn't output a confusing error message about a failed child process. Instead it leaves printing error messages to the child process.

Thank to Simon Hengel for submitting a PR for this!

Remove unused flake inputsshare

The generated flake files now only include flake inputs that are actually used. This is more an internal detail, but it's included here, since it means that Garn should run a little faster now.

Continue Reading

May 14, 2024Sönke Hahn, Alex David, Julian Arni

A simpler, more composable Haskell process library

Mar 14, 2024Julian K. Arni

What happens if we make URLs immutable? A somewhat unusual idea that can substantially improve and simplify deployments.

Dec 19, 2023Alex David

Microsoft's LSP is great for text-editor diversity, but it is severely lacking in flexibility for project-specific configuration.

View Archive
black globe

Say hi, ask questions, give feedback