Skip to content

Latest commit

 

History

History
164 lines (124 loc) · 3.59 KB

README.md

File metadata and controls

164 lines (124 loc) · 3.59 KB

Taco

It's a wrapper around your commands!

Eh? What are you talking about...

Let's imagine you have 2 projects, and you want to run tests in each project.

  1. Project A, is a Laravel PHP project, so you want to use phpunit or pest.
  2. Project b, is a JavaScript project, so you want to use jest or npm run test.

I don't want to remember all of that... Let's fix it.

cd ~/projects/php_project_a
taco add test -- phpunit

cd ~/projects/js_project_b
taco add test -- npm run test

So what happened here? We created aliases!

This is what the config looks like in ~/.config/taco/taco.json

{
  "projects": {
    "/Users/robin/projects/php_project_a": {
      "test": "phpunit"
    },
    "/Users/robin/projects/js_project_b": {
      "test": "npm run test"
    }
  }
}

From now on, I can just write taco test regardless of the project I am in, and it will execute the corresponding command. This is awesome because I work in a lot of different projects, and a lot of them are not even mine. It would be stupid to change all the scripts for each project just because I like npm run tdd instead of npm run test:watch as a script name.

Inheritance

Scripts inherit scripts from parent directories. This allows you to set the npm run test only once in a shared folder. In my case, I did this in a ~/github.com/tailwindlabs folder.

This is how I use it personally:

{
  "projects": {
    "/Users/robin/github.com": {
      "tdd": "./node_modules/.bin/jest --watch",
      "test": "./node_modules/.bin/jest"
    },
    "/Users/robin/github.com/tailwindlabs": {
      "dev": "next dev"
    },
    "/Users/robin/github.com/tailwindlabs/tailwindcss": {
      "build": "bun run swcify",
      "watch": "bun run swcify --watch"
    },
    "/Users/robin/github.com/tailwindlabs/headlessui": {
      "vue": "yarn workspace @headlessui/vue",
      "react": "yarn workspace @headlessui/react"
    }
  }
}

Requirements

  • This is a Rust project and the binaries are not published anywhere. This means that you need to have Rust/Cargo installed.

Installation

cargo build --release

This will create a taco binary at ./target/release/taco.

Optional quality of life improvements

I am using zshrc, and I make sure to export the ./target/release/ folder so that I can automatically run the taco binary.

PATH=./target/release:$PATH

In addition, I also have this PATH, so that I can run taco from anywhere on my system.

PATH=/path-to-taco-project/target/release:$PATH

API

Add – taco add {name} -- {command}

taco add ls -- ls -lah
# Aliased "ls" to "ls -lah" in /Users/robin

Execute – taco {name} -- {passthrough arguments}

taco ls 
# total 680
# total 680
# drwxr-x---+ 59 robin  staff   1.8K Dec  1 21:06 .
# drwxr-xr-x   5 root   admin   160B Nov 15 18:46 ..
# -rw-r--r--@  1 robin  staff    18K Dec  1 19:38 .DS_Store
# drwx------+ 56 robin  staff   1.8K Nov 29 18:43 .Trash
# ...

Or if you want to look at the command that is going to be executed use the --print flag.

taco ls --print
# ls -lah

Print – taco print

taco print
# Available commands:
#
#   taco test
#     ./node_modules/.bin/jest
#
#   taco ls
#     ls -lah
#
# 2 commands

Or..

taco print --json
# {
#   "ls": "ls -lah",
#   "test": "./node_modules/.bin/jest"
# }

Remove – taco rm {name}

taco rm ls
# Removed alias "ls"

Inspired by the awesome Projector tool by ThePrimeagen!