Settings

Theme

Show HN: Platform-aware script runner for Node.js projects

github.com

3 points by carlos-menezes 5 days ago · 0 comments · 1 min read

Reader

Hey HN.

I made this to scratch my own itch when trying to run scripts for different operating systems (Windows and Mac) and architectures (Intel Mac and M3 Max Mac).

If you maintain a monorepo or work across Mac (Intel + Apple Silicon) and Linux/Windows, you've probably copy-pasted platform-specific commands into your CI or kept a wall of if statements in shell scripts.

`target-run` lets you define platform/arch variants of any `npm` script using a naming convention:

  {
    "scripts": {
      "build": "target-run",
      "build:darwin:arm64": "node dist/index-darwin-arm64.js",
      "build:linux:x64": "node dist/index-linux-x64.js",
      "build:default": "node dist/index.js"
    }
  }
Running `pnpm build` dispatches to the right variant automatically, falling back through `platform:arch`, `platform`, `arch` and, finally, `default`.

The README has more details on usage and options. Thanks for checking it out.

No comments yet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection