🚲 do something when, a text parser with purpose
Have you ever had a process that takes a long time to finish? Ever want to be alerted or have something happen when that is done? Maybe a long grep or a process that takes awhile to build, but don't have control over the underlying tooling?
ls . | grep "foo" | run-then
This will check the rules at the following locations:
/{homedir}/.runrc
/{cwd}/.runrc
An example can be found in
/example
with aREADME
to show how to run it.
module.exports = {
default: [{
when: /^foo bar/,
do: async function() {
console.log('hi');
}
}],
verbose: [{
when: /(.+?)/,
noOutput: true,
do: async function(data) {
console.log(`${Date()} ${data.trim()}`);
}
}],
finished: [{
onExit: true,
do: async function(data) {
console.log('done!');
}
}]
}
The default command will be executed when run like:
ls . | grep "foo" | run-then
Rules can be chained or run one at a time like such:
ls . | grep "foo" | run-then verbose finished