Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dherault/loopa
A loop for npm scripts
https://github.com/dherault/loopa
Last synced: 23 days ago
JSON representation
A loop for npm scripts
- Host: GitHub
- URL: https://github.com/dherault/loopa
- Owner: dherault
- License: mit
- Created: 2020-05-24T19:16:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-25T14:55:33.000Z (8 months ago)
- Last Synced: 2024-05-02T00:56:45.613Z (6 months ago)
- Language: JavaScript
- Size: 36.1 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# loopa
Loopa is a for loop for scripts. It will execute a command n times before exiting.
## Installation
`npm install --dev loopa` or `npx loopa`
## Usage
`loopa 3 echo "a loop"`
```
a loop
a loop
a loop
````loopa 10 npm run some-script`
```
(some-script executed 10 times)
````loopa infinity echo "an infinite loop"`
```
an infinite loop
an infinite loop
an infinite loop
...
````loopa 3 1000 echo "one second interval"`
```
one second interval
one second interval
one second interval
```## Usage with environment variables
Environment variables should be escaped:
`FOO=foo loopa 100 echo \$FOO`
```
foo
foo
foo
...
```If you do not like escaping your environment variables you can do the following in your package.json file:
```json
{
"scripts": {
"loop": "loopa 100 npm run echo-foo",
"echo-foo": "FOO=foo echo $FOO"
}
}
```## Accessing the iteration variable
The iteration variable is available under the `$I` (or `\$I`) env variable:
`loopa 4 echo \$I`
```
0
1
2
3
```## License
MIT