Skip to content

schmich/runx

Repository files navigation

runx

Cross-platform, zero-install, Ruby-based task runner.

Setup

Download the zero-install binary to a directory on your PATH.

Usage

Create a Runfile with your tasks:

doc 'Start server.'
run :up do
  system 'docker-compose -f services.yml -f env.yml up --build'
end

doc 'Stop server.'
run :down do
  system 'docker-compose -f services.yml -f env.yml down'
end

doc 'Create database migration.'
run 'migrate:make' do |*args|
  system *%w(docker-compose -f services.yml -f env.yml exec app php /src/artisan migrate:make) + args
end

Run runx to see available tasks:

$ runx
Tasks:
  up                Start server.
  down              Stop server.
  migrate:make      Create database migration.

Run runx <task> to run a task:

$ runx up
Building app
Step 1 : FROM php:7-fpm-alpine
 ---> a0955c912431
...

$ runx migrate:make create_some_table
Created Migration: 2016_10_06_133147_create_some_table
Generating optimized class loader

Parent directories are searched up to the root until a Runfile is found, so you can use runx in subdirectories, too.

How It Works

The Go-built runx binary contains an OS-specific version of Phusion's Traveling Ruby runtime, embedded with Jim Teeuwen's go-bindata. At runtime, the Ruby distribution is extracted to ~/.runx/<hash>, the runx binary spawns ruby, which loads the runx Ruby library, which loads the Runfile and runs tasks.

License

Copyright © 2016 Chris Schmich
MIT License. See LICENSE for details.