In this article I will show you an awesome NPM tool that I created called repeat-cli-command. It is open source and I invite you to contribute to it. This tool allows you to repeat any CLI command effortlessly for an X number of times.
Whether you are running tests, debugging, or just want to loop a command, this tool has you covered.
Let’s dive in!
Installation
First, install it globally (-g) or at project level (-D) with npm.
npm install -g repeat-cli-command
Usage
Let's say we want to repeat a simple command like printing "Hello" to the terminal, for 5 times. We just run
npx repeat-cli-command "echo 'Hello' " --times=5
Now, let’s say you’re working with PactumJS for API testing (or any other testing framework) and want to rerun the tests for 10 times.
npx repeat-cli-command 'npx mocha api_tests --timeout=10000' --times=10
What if you have some web e2e automated tests with TestCafe? No problem!
npx repeat-cli-command 'npx testcafe chrome:headless web_tests' --times=2
Simple, isn’t it?
This is how you can use repeat-cli-command to boost productivity! It works with any CLI command and can become handy for testing, debugging, and much more.
Post Views: 410
