4 ms·
Using `make` with `.PHONY` targets is what I'd call a "task runner". -- In NodeJS, a package.json's "scripts" serve a similar task. I think the main/only reaso
by rgoulter 4y ago
Using `make` with `.PHONY` targets is what I'd call a "task runner". -- In NodeJS, a package.json's "scripts" serve a similar task.
I think the main/only reason to go out of your way to use `make` as a task runner is its ubiquity.
However, if you're already using nix, it's probably not much of an issue to use a better task runner.
I'd recommend 'just' instead https://github.com/casey/just https://github.com/casey/just -- It has a nicer UX, with a few significant quality-of-life improvements out-of-the-box compared to `make`. e.g.
- you can get a list of tasks, and select one using `fzf` with `just --choose`.
- can inline use of bash, or python, etc.
- `just` automatically searches up a directory tree for a `justfile`.
- wdroz 4y agoI switched to Just for most of my projects. The only thing I miss from Make is the possibility to run the tasks in parallel.
- zelphirkalt 4y agoNPM has no concept of dependencies of steps like make has for what people use in "scripts". It is painful to see people doing that all the time and then constructing their commands as long strings, which the tool they use has no knowledge about, using recursive invocation and having to write "npm run" again and again in those long strings, while in a Makefile it is all figured out automatically, as dependencies of steps are clearly stated as such. It feels akin to handling HTML as a long string and fumbling around in it, as was done in the past in many PHP projects, instead of handling HTML as structured data, an XML tree or similar. NPM package.json scripts is a Makefile for the very poor. Yes it can be used like that. Should it? When commands start to have prerequisites probably not.
- pcthrowaway 4y agoIf one script has a dependency on another script, just have the dependent script defined as `"npm run otherscript && ..."` You still don't get to define output files as dependencies, so it's not quite Make, but it's really not that bad if your project is already node/js/ts
- yjftsjthsd-h 4y ago> I think the main/only reason to go out of your way to use `make` as a task runner is its ubiquity. In fairness, that's a pretty big reason.
- rgoulter 4y agoFor projects where you need to collaborate with others, yeah. For personal projects like "how I generate my static site", and where you're already using a tool like nix, 'tool already installed' isn't worth going out of your way for.
- pxc 4y agoRight. For personal projects, once you're using Nix you're really free to prioritize basically anything else over package availability. That's one of the joys of it!