Skip to content

nxtcoder17/Runfile

Repository files navigation

Runfile is a super simple task runner

All it does is run some pre-configured tasks for you, like running your applications, tests, building binaries, or some other scripts.

It is inspired by other task runners like Taskfile, Make etc. I decided to build my version of it, accounting the experiences that i want to see in a task runner.

Features

  • Run tasks (commands)
  • Run tasks with Key-Value environment variables
  • Run tasks with dynamic environment variables (referencing values by shell execution)
  • Run tasks with dotenv files as their environment variables
  • Importing tasks from different working directory (must in a monorepo) reference
  • Running tasks in parallel (e.g. css generation and build in parallel)
  • Running tasks with watch mode (e.g. like hot reload)
  • Requirements prior to running a target (e.g. sanity tests)
  • Environment validations and default value

Installation

Tool Command
Go go install github.com/nxtcoder17/runfile/cmd/run@latest
go install github.com/nxtcoder17/runfile/cmd/run@latest

Usage

Runfile

Create a Runfile in the root of your project, and add tasks to it.

Examples

  1. simple tasks
tasks:
  example:
    cmd:
        - echo "example"

Output

  1. using environment variables
tasks:
  example:
    env:
      key: "hello world"
    cmd:
      - echo $key

Output

  1. using dynamic environment variables
tasks:
  example:
    env:
      key: 
        sh: echo $HOME
    cmd:
      - echo $key

Image

  1. using dotenv based environment variables
tasks:
  example:
    dotenv:
      - .env
    cmd:
      - echo $key
# file: .env
key="my-dotenv-secret"

Image

  1. validating required environment variable
tasks:
  example:
    env:
      key:
        required: true
    cmd:
      - echo $key

Image

  1. referencing other tasks
tasks:
  script1:
    cmd:
      - echo "i am script 1 (key=$key)"

  example:
    cmd:
      - run: script1
        env:
          key: "hello"
      - echo this is example (key=$key)

Image