zzarcon / Run When
Licence: mit
Run tasks based on "Git diff" changes 🏃 ➕ ➖
Stars: ✭ 63
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Run When
Mask
🎭 A CLI task runner defined by a simple markdown file
Stars: ✭ 495 (+685.71%)
Mutual labels: cli, task, task-runner
concurrent-tasks
A simple task runner which will run all tasks till completion, while maintaining concurrency limits.
Stars: ✭ 27 (-57.14%)
Mutual labels: task, task-runner
rush
🏃♀️ Minimalistic CLI Tool for Managing and Running Bash Snippets
Stars: ✭ 35 (-44.44%)
Mutual labels: task, task-runner
Replace In File
A simple utility to quickly replace contents in one or more files
Stars: ✭ 369 (+485.71%)
Mutual labels: cli, glob
Foy
A simple, light-weight and modern task runner for general purpose.
Stars: ✭ 157 (+149.21%)
Mutual labels: cli, task-runner
Topydo
A powerful todo list application for the console, using the todo.txt format.
Stars: ✭ 511 (+711.11%)
Mutual labels: cli, task
composer
API-first task runner with three methods: task, run and watch.
Stars: ✭ 35 (-44.44%)
Mutual labels: task, task-runner
Npm Build Boilerplate
A collection of packages that build a website using npm scripts.
Stars: ✭ 963 (+1428.57%)
Mutual labels: cli, task
Ten Hands
⚡ Simplest way to organize and run command-line tasks
Stars: ✭ 228 (+261.9%)
Mutual labels: cli, task-runner
lets
CLI task runner for developers - a better alternative to make
Stars: ✭ 50 (-20.63%)
Mutual labels: task, task-runner
Task
A task runner / simpler Make alternative written in Go
Stars: ✭ 4,282 (+6696.83%)
Mutual labels: task, task-runner
Taskwarrior
Taskwarrior - Command line Task Management
Stars: ✭ 2,239 (+3453.97%)
Mutual labels: cli, task
Dstask
Single binary terminal-based TODO manager with git-based sync + markdown notes per task
Stars: ✭ 431 (+584.13%)
Mutual labels: cli, task
Run tasks based on git diff files
Usage
Having this directory tree with the following files changed:
├── app
├────── components
├ ├── index.js
├ ├── app.jsx
└── __tests__
├ ├── app.spec.jsx
└── package.json
run-when
will check glob rules against it and run tasks if any changes have been made.
Javascript
import runWhen from 'run-when';
runWhen([
{
glob: ['app/components/index.js', 'app/__tests__/**'],
task(paths) {
console.log('This will be called!');
}
},
{
glob: ['!package.json'],
task(paths) {
return Promise.resolve('You can return a promise from your task');
}
},
{
// Optionally pass changed files
changedFiles: () => Promise.resolve(['app/index.js', 'app/components/header.jsx']),
glob: ['app/components/**'],
task(paths) {
console.log(paths === ['app/components/header.jsx']);
}
}
]);
CLI
$ run-when '["app/components/**", "app/utils/**"]' 'echo running tests... && yarn test'
- First argument is a stringified JSON containing glob patterns.
- Second argument is the task to run.
How it works
By default run-when
will use git to know which files have been changed. You can change that
passing an array of files to changedFiles
.
Globbing pattern
The library uses multimatch for the globbing matching (sindresorhus 😻). Just a quick overview:
-
*
matches any number of characters, but not/
-
?
matches a single character, but not/
-
**
matches any number of characters, including/
, as long as it's the only thing in a path part -
{}
allows for a comma-separated list of "or" expressions -
!
at the beginning of a pattern will negate the match
Various patterns and expected matches.
Api
type Files = Array<string>;
interface Rule {
glob: Array<string>,
task: (results: Files) => void,
changedFiles?: () => Promise<Files>
}
type runWhen = (rules: Array<Rule>) => Promise;
Installation
$ yarn add run-when -D
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].