{"id":17442548,"url":"https://github.com/jez/bask","last_synced_at":"2025-10-23T20:48:01.172Z","repository":{"id":73797487,"uuid":"62438339","full_name":"jez/bask","owner":"jez","description":":sunglasses: Bask in the convenience of a task runner for bash","archived":false,"fork":false,"pushed_at":"2018-03-07T11:38:52.000Z","size":38,"stargazers_count":60,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-18T13:39:54.978Z","etag":null,"topics":["bash","cli","task-runner"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-02T06:59:37.000Z","updated_at":"2025-05-05T20:56:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"456fa3b0-7fe3-4a02-a61e-eff563368315","html_url":"https://github.com/jez/bask","commit_stats":{"total_commits":32,"total_committers":4,"mean_commits":8.0,"dds":0.125,"last_synced_commit":"5ebbd03c17c23accb223df3f7c27ca7f549741ca"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jez/bask","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fbask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fbask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fbask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fbask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jez","download_url":"https://codeload.github.com/jez/bask/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fbask/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260951201,"owners_count":23087659,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","cli","task-runner"],"created_at":"2024-10-17T16:16:38.569Z","updated_at":"2025-10-23T20:48:01.077Z","avatar_url":"https://github.com/jez.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bask\n\n[![Travis](https://img.shields.io/travis/jez/bask.svg?maxAge=2592000)](https://travis-ci.org/jez/bask)\n[![npm](https://img.shields.io/npm/v/bask.svg?maxAge=2592000)](https://www.npmjs.com/package/bask)\n[![Gitter](https://img.shields.io/gitter/room/jez/bask.svg?maxAge=2592000)][gitter]\n[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-brightgreen.svg)](https://github.com/RichardLitt/standard-readme)\n[![tl;drLegal LGPL 3.0](https://img.shields.io/badge/tl%3BdrLegal-LGPL_3.0-blue.svg)](https://tldrlegal.com/license/gnu-lesser-general-public-license-v3-(lgpl-3))\n\n\u003e :sunglasses: Bask in the convenience of a task runner for bash\n\nBask is a task runner for Bash. It's like Make with a bunch of shell targets,\nbut without the `.PHONY`'s everywhere, and nicer because there's no more Make\nsyntax. The main difference is that tasks are always run in Bask, but only run\nif targets are out of date in Make.\n\nIf you're writing a Makefile with all `.PHONY` targets, chances are that Bask is\nreally what you want.\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n  - [Simple (vendored)](#simple-vendored)\n  - [Submodule (vendored)](#submodule-vendored)\n  - [Homebrew](#homebrew)\n  - [NPM](#npm)\n  - [Git + PATH](#git--path)\n- [Usage](#usage)\n- [CLI](#cli)\n  - [Flags](#flags)\n  - [Tab Completion](#tab-completion)\n- [API](#api)\n  - [Baskfile](#baskfile)\n    - [Default Tasks](#default-tasks)\n  - [Methods](#methods)\n    - [`bask_depends`](#bask_depends)\n    - [`bask_fork_join`](#bask_fork_join)\n    - [`bask_run`](#bask_run)\n    - [`bask_log`](#bask_log)\n    - [`bask_colorize`](#bask_colorize)\n    - [`bask_list_tasks`](#bask_list_tasks)\n    - [`bask_is_task_defined`](#bask_is_task_defined)\n- [Contribute](#contribute)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Background\n\nBask was initially forked from [bash-task-runner]. It was forked for a couple\nreasons:\n\n- I needed to vendor it for an unrelated project.\n- I wanted to drop the dependency on GNU coreutils.\n- I wanted to improve the name :smirk:\n\nI actively follow upstream changes. If I'm missing a compatible feature that was\nadded upstream, feel free to notify me via an issue, pull request, or message on\nGitter.\n\nBask's first commit is a squashed version of `bash-task-runner` at the time it\nwas forked. For a complete list of changes, just use the commit log.\n\n\n## Install\n\nEach of the below installation methods is differentiated along two properties:\n\n- **Local to project**\n  - Whether Bask will be installed locally to your project or globally on a\n    system.\n  - This is good for CI builds and spinning up multiple people on your project\n- **CLI-enabled**\n  - Whether you will be able to use the `bask` command from your prompt.\n  - Useful for local development, tab completion, and convenience.\n\nYou may want to combine multiple installation methods in order to satisfy both\nof these requirements. In particular, we recommend [**Simple\n(vendored)**](#simple-vendored) with a method that gives you a CLI and is\ncompatible with your system.\n\n|                      | Local to Project   | CLI-enabled        |\n| ---                  | ---                | ---                |\n| Simple (vendored)    | :white_check_mark: | :no_entry_sign:    |\n| Submodule (vendored) | :white_check_mark: | :white_check_mark: |\n| Homebrew             | :no_entry_sign:    | :white_check_mark: |\n| NPM                  | :white_check_mark: | :white_check_mark: |\n| Git + PATH           | :no_entry_sign:    | :white_check_mark: |\n\n### Dependencies\n\nCurrently Bask requires Bash 4.2+.\n\n### Simple (vendored)\n\nJust drop `src/bask.sh` anywhere in your project folder:\n\n```shell\nwget https://raw.githubusercontent.com/jez/bask/master/src/bask.sh\n```\n\nThen skip to [Usage](#usage) for how to use a vendored Bask installation.\n\n### Submodule (vendored)\n\nIf you'd like a slightly better story around updating Bask when vendored, you\ncan use a Git submodule, if you're [familiar with submodules][submodules]:\n\n```shell\ngit submodule add https://github.com/jez/bask\n```\n\n\u003e Note that if submodules are too heavy-handed, you can get the same effect\n\u003e (without the ease of updating) by just unzip'ing Bask's source into your\n\u003e project.\n\nYou should now be able to access `bask.sh` within the submodule. Additionally,\nyou can access the CLI with `./bask/bin/bask`. You can make this more ergonomic\nby altering your PATH:\n\n```shell\nexport PATH=\"$PATH:./bask/bin\"\n```\n\nThen skip to [Usage](#usage) to learn more.\n\n### Homebrew\n\nOn OS X, installing Bask globally is simple if you have Homebrew:\n\n```shell\nbrew install jez/formulae/bask\n```\n\nThen skip to [Usage](#usage) to learn more.\n\n### NPM\n\nIf you don't mind the additional dependency on the NPM ecosystem, you can\ninstall Bask with NPM:\n\n```shell\n# --- Local to Project --- #\nnpm install --save bask\n\n# to enable CLI:\nexport PATH=\"PATH:./node_modules/.bin\"\n\n# --- Global --- #\nnpm install -g bask\n```\n\nThen skip to [Usage](#usage) to learn more.\n\n### Git + PATH\n\nIf Bask is not available in a package manager for your system, you can clone\nBask to your computer, and adjust your PATH to contain the installation\nlocation:\n\n```\ngit clone https://github.com/jez/bask\n\nexport PATH=\"$PATH:$(pwd)/bask/bin\"\n```\n\nThen skip to [Usage](#usage) for how to use the CLI.\n\n\n## Usage\n\nYou use Bask in conjunction with a `Baskfile`. A basic `Baskfile` looks like\nthis:\n\n```shell\ntask_foo() {\n  ## Do something...\n}\n\ntask_bar() {\n  ## Do something...\n}\n```\n\n**Optional**: if you want your `Baskfile` to be a standalone script, add this\nto the beginning (works best in conjunction with a vendored installation):\n\n```shell\n#!/usr/bin/env bash\ncd \"$(dirname \"$0\")\" || exit\nsource ./path/to/bask.sh\n```\n\nYou invoke Bask using `bask [task ...]`:\n\n```console\n$ bask foo bar\n[21:37:43.754] Starting 'foo'\n[21:37:43.755] Finished 'foo' after 1 ms\n[21:37:43.756] Starting 'bar'\n[21:37:43.757] Finished 'bar' after 1 ms\n```\n\nOr, if your `Baskfile` sources `bash.sh`:\n\n```console\nbash Baskfile foo bar\n```\n\n## CLI\n\nNOTE: Please see `bask -h` for complete, up-to-date CLI usage information.\n\n```\nUsage: bask [options] [task] [task_options] ...\nOptions:\n  -C \u003cdir\u003e, --directory=\u003cdir\u003e  Change to \u003cdir\u003e before doing anything.\n  --completion=\u003cshell\u003e         Output code to activate task completions.\n                               Supported shells: 'bash'.\n  -f \u003cfile\u003e, --file=\u003cfile\u003e     Use \u003cfile\u003e as a Baskfile.\n  -l, --list-tasks             List available tasks.\n  -h, --help                   Print this message and exit.\n```\n\n### Flags\n\nAll flags you pass after the task names are passed to your tasks.\n\n```bash\ntask_foo() {\n  echo ${@}\n}\n\n$ bask foo --production\n--production\n```\n\nTo pass options to the `bask` CLI specifically, you must provide them\nbefore any task names:\n\n```bash\n$ bask -f scripts/tasks.sh foo\n```\n\n### Tab Completion\n\nThe `bask` CLI supports autocompletion for task names (bash only). Simply add\nthe following line your `~/.bashrc`:\n\n```shell\neval $(bask --completion=bash)\n```\n\n\n## API\n\nThis section covers all the features of Bask.\n\n### Baskfile\n\nYour Baskfile can be named any of the following. Using a `.sh` suffix helps with\nthings like editor syntax highlighting.\n\n```\nBaskfile\nBaskfile.sh\nbaskfile\nbaskfile.sh\n```\n\n\n#### Default Tasks\n\nYou can specify a default task in your Baskfile. It will run when no arguments\nare provided. There are two ways to do this:\n\n```shell\ntask_default() {\n  # do something ...\n}\n```\n\n```shell\nbask_default_task=\"foo\"\ntask_foo() {\n  # do something ...\n}\n```\n\n\n### Methods\n\nBask exposes a number of functions for manipulating dependencies among tasks,\nfor logging, and for a few utilities.\n\n#### `bask_depends`\n\n\u003e Alias: `bask_sequence`\n\nThis function is for declaring dependencies of a task. It should be invoked\nwithin another task.\n\nUsage: `bask_depends [task ...]`\n\n```shell\ntask_default() {\n  bask_depends foo bar\n  # Output:\n  # [21:50:33.194] Starting 'foo'\n  # [21:50:33.195] Finished 'foo' after 1 ms\n  # [21:50:33.196] Starting 'bar'\n  # [21:50:33.198] Finished 'bar' after 2 ms\n}\n```\n\nIf any task return non-zero, the entire sequence of tasks is aborted with\nan error.\n\nNote that return codes can be bubbled up using `... || return`, so you can\nconveniently abort tasks prematurely like this:\n\n```\nmaybe_error() {\n  return $(($RANDOM % 2))\n}\n\ntask_try() {\n  echo \"Bad\"\n  maybe_error || return    # \u003c-- bubbles error up if error\n  # code for when no error\n}\n\ntask_finally() {\n  echo \"Good\"\n}\n\ntask_foo() {\n  bask_depends try finally\n}\n```\n\n#### `bask_fork_join`\n\n\u003e Alias: `bask_parallel`\n\nBask also allows for spawning independent work in parallel, and resuming the\ntask when all tasks have completed:\n\nUsage: `bask_fork_join [task ...]`\n\n```shell\ntask_default() {\n  bask_fork_join sleep3 sleep5\n  bask_log \"after\"\n  # [21:50:33.194] Starting 'sleep3'\n  # [21:50:33.194] Starting 'sleep5'\n  # [21:50:36.396] Finished 'sleep3' after 3.20 s\n  # [21:50:38.421] Finished 'sleep5' after 5.23 s\n  # [21:50:38.422] after\n}\n```\n\nNote that all tasks always run to completion, unlike with `bask_depends`.\n\n#### `bask_run`\n\nThis will log a timestamp plus the command with its arguments, then run it.\n\nUsage: `bask_run \u003ccommand --with args\u003e`\n\nNote that the command must be a simple command--things like pipes, `\u0026\u0026`, `||`,\n`{ ... }`, etc. will not work.\n\n\n#### `bask_log`\n\nYou can log information inside Bask tasks using one of the five `bask_log`\nhelpers:\n\n| Function           | Description                                          |\n| ---                | ---                                                  |\n| `bask_log`         | Adds a log line (with time), in the foreground color |\n| `bask_log_success` | Same as above, but in green                          |\n| `bask_log_error`   | Same as above, but in red                            |\n| `bask_log_warning` | Same as above, but in yellow                         |\n| `bask_log_info`    | Same as above, but in cyan                           |\n| `bask_log_debug`   | Same as above, but in gray                           |\n\nUsage: `bask_log message`\n\nAll logging functions have the same usage.\n\n#### `bask_colorize`\n\nWhile the dedicated logging functions are helpful, sometimes you want finer\ncontrol over your colors.\n\nUsage: `bask_colorize \u003ccolorname\u003e message`\n\nWhere `colorname` is one of\n\n|           |             |              |            |              |            |\n| ---       | ---         | ---          | ---        | ---          | ---        |\n| black     | gray        | light_gray   | white      |              |            |\n| red       | green       | yellow       | blue       | purple       | cyan       |\n| light_red | light_green | light_yellow | light_blue | light_purple | light_cyan |\n\n```shell\n# Simple example\nbask_colorize purple This will all be purple\n\n# Use with `bask_log` to get a timestamp:\nbask_log \"$(bask_colorize purple This will all be purple)\"\n```\n\nNote that your message will be wrapped with the appropriate color **and** reset\ncodes. You don't need to worry about manually turning the color back to normal.\n\n#### `bask_list_tasks`\n\nThe default behavior if no tasks are specified at the command line and no\ndefault tasks are registered is to list all available tasks. You can manually\ninvoke that with this function.\n\nUsage: `bask_list_tasks`\n\n```shell\ntask_list() {\n  bask_list_tasks\n}\n```\n\n#### `bask_is_task_defined`\n\nUtility function for checking whether a list of tasks are defined. Used\ninternally, but exposed externally.\n\nUsage: `bask_is_task_defined [task ...]`\n\nNote that you can pass in more than one task for checking.\n\nAlternatively, you can use `bask_is_task_defined_verbose`, which will do the\nsame checks, but log an error if any task is not defined.\n\n\n## Contribute\n\nBask was forked from [bash-task-runner]. Chances are that if you have an issue\nor pull request it can be made against that upstream repo.\n\nIf your issue pertains to functionality specifically only provided here, then\nfeel free to voice your concerns here. If you're confused where to make the\nrequest, feel free to ask in [Gitter][gitter] first.\n\n## License\n\nGNU Lesser General Public License v3 (LGPL-3.0). See License.md\n\n| Copyright (c)   | Commits  |\n| --------------- | -------- |\n| Aleksej Komarov | 8a28f72  |\n| Jake Zimmerman  | 5e92344+ |\n\n\u003c!-- TODO(jez): Update commit after --amend --\u003e\n\n[bash-task-runner]: https://github.com/stylemistake/bash-task-runner\n[gitter]: https://gitter.im/jez/bask\n[submodules]: https://git-scm.com/book/en/v2/Git-Tools-Submodules\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjez%2Fbask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjez%2Fbask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjez%2Fbask/lists"}