« Back to Index

Rust Cargo Guardfile

View original Gist on GitHub

Guardfile

require "terminal-notifier-guard"

guard :shell do
  watch(/src\/(.*\/)?(.*)\.rs$/) do |path, folder, file|
    p "Path: #{path}"
    p "Folder: #{folder}"
    p "File: #{file}"

    binary_name = `sed -ne 's/name = "\\(.*\\)"/\\1/p' Cargo.toml | tail -n 1`

    `cargo build && ./target/#{binary_name}`
  end
end