just のインストール:justfile 作成、recipe 実行、make との比較
just を入れ justfile で recipe を回し、make との使い分けを押さえる。
lint → test → build を README に書いても誰も見ない。just は justfile で recipe を定義し just で実行するコマンドランナーです。本稿は macOS/Linux インストール、justfile 作成、recipe 実行、make との比較 を hereink 向けにまとめます。
検索語はjust のインストールと justfile で recipe を実行 make との違い。just --version、最初の recipe、just --list までできれば OK です。
導入brew · cargo
設定justfile
実行just · --list
installjustfilejust test
just が解くこと
発見可能なタスク
just --list で recipe 一覧。
スクリプトより軽い
変数・依存・引数を justfile に集約。
公式:
github.com/casey/just、just.systems。
インストール
- 1macOS
brew install just。 - 2Linux
Arch:
pacman -S just。古い distro はcargo install just。 - 3cargo
cargo install just、PATHに~/.cargo/bin。 - 4mise
mise use -g just@latest。
justfile
default:
just --list
test:
cargo test
check: lint test
echo "ok"
lint:
cargo clippy -- -D warnings実行
just --list
just test
just -n testmake との比較
| just | make | |
|---|---|---|
| 用途 | タスクランナー | ビルドグラフ |
| Windows | ドキュメント充実 | GNU make / WSL 依存が多い |
- 向く
- polyglot repo、統一
dev/test。 - make のまま
- 增量ビルドが中心の C/C++。
npm scripts と重複?
recipe から npm run を呼べる。Node 専用なら npm だけでも可。
.env は?
set dotenv-load を justfile に(公式マニュアル参照)。