# loop-things

> loop through commands in fun and amazing ways!

Latest version **0.0.23** (published 2017-03-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install loop-things
pnpm add loop-things
yarn add loop-things
bun add loop-things
```

Provides the command `loop`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.23 |
| Published | 2017-03-29 |
| First published | 2016-12-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 136 |
| Author | hi@iammwattwalters.com |
| Maintainers | mateodelnorte |
| Keywords | loop, command, commands |

## Links

- npm: https://www.npmjs.com/package/loop-things
- Repository: https://github.com/mateodelnorte/loop-things
- Homepage: https://github.com/mateodelnorte/loop-things#readme
- Issues: https://github.com/mateodelnorte/loop-things/issues
- npm.io page: https://npm.io/package/loop-things

## Dependencies (8)

- [async](https://npm.io/package/async.md) ^2.1.4
- [chalk](https://npm.io/package/chalk.md) ^1.1.3
- [debug](https://npm.io/package/debug.md) ^2.3.3
- [mocha](https://npm.io/package/mocha.md) ^3.2.0
- [yargs](https://npm.io/package/yargs.md) ^6.5.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.2
- [should](https://npm.io/package/should.md) ^11.1.2
- [meta-exec](https://npm.io/package/meta-exec.md) 0.0.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.0.23 (latest) — 2017-03-29
- 0.0.22 — 2017-02-07
- 0.0.21 — 2017-01-24
- 0.0.20 — 2017-01-05
- 0.0.19 — 2017-01-02
- 0.0.18 — 2016-12-24
- 0.0.17 — 2016-12-24
- 0.0.16 — 2016-12-23
- 0.0.15 — 2016-12-19
- 0.0.14 — 2016-12-15
- 0.0.13 — 2016-12-15
- 0.0.12 — 2016-12-14
- 0.0.11 — 2016-12-14
- 0.0.10 — 2016-12-14
- 0.0.9 — 2016-12-14
- … 9 more at https://npm.io/package/loop-things/versions

## README

# loop-things

loop-things expands commands to work simultaneously against any number of subdirectories in your current working path. Want to perform a `git status` on 15 projects at once? With loop-things, you can do it!

```
    loop executes a command against child directories within its current working directory

    usage:

      loop [command]                                      - execute a command against all child dirs
      loop ["command with multiple words in quotes"]      - execute a multi-word command against all child dirs
      loop --cwd ../other/working/directory               - execute a command against all child dirs, setting the working directory to another directory
      loop --include comma,delimited,list,of,dirs         - execute a command against all child dirs including a number of directories which might otherwise be ignored, for instance, in .looprc
      loop --include-only comma,delimited,list,of,dirs    - execute a command against all child dirs, ignoring .looprc, and only including the specified directories
      loop --exclude comma,delimited,list,of,dirs         - execute a command against all child dirs, excluding the specified directories
      loop --exclude-only comma,delimited,list,of,dirs    - execute a command against all child dirs, excluding only the specified directories
      loop --init                                         - creates a .looprc in the current working directory

    examples:

      loop pwd
      loop "git status"
      loop "git checkout -b feature/new-feature"
      loop "git push origin feature/new-feature"

    .looprc:

      directories containing a .looprc json file may have extra behavior, determined by properties within the file:

        ignore (type Array) any child directory names listed in ignore will be ignored and skipped from execution

    example .looprc:

    {
      "ignore": [ ".git", ".vagrant", ".vscode", "ansible", "node_modules", "scripts" ]
    }
```

## Installation

`npm install -g loop-things`

## Basic Usage

loop-things installs a `loop` command which you can leverage from the command line, in your package.json scripts, etc. The syntax is super simple. Just `loop [your command]`. If the command you wish to run consists of multiple words, place the command in quotes: `loop "your --you | really -R | long -o | command"`. 

In a folder with the following structure: 
```
./git
./bin
./lib
./node_modules
./test
./index.js
./package.json
```

executing `loop pwd` yields the following results: 
```
➜  nycnode-site git:(master) loop pwd

.git
/Users/mateodelnorte/development/nycnode/nycnode-site/.git

lib
/Users/mateodelnorte/development/nycnode/nycnode-site/lib

node_modules
/Users/mateodelnorte/development/nycnode/nycnode-site/node_modules

test
/Users/mateodelnorte/development/nycnode/nycnode-site/test
```

## .looprc

loop can use a `.looprc` file to customize how loop behaves in a particular folder. Installing a `.looprc` file to a folder is simple: 

`loop --init` results in the following file being created: 

```
{
  "ignore": [ ".git", ".vagrant", ".vscode", "node_modules" ]
}
```

Now, when we perform the same command we did previously `loop pwd`, `loop` will recognize the `.looprc` file and see the `.git` folder is ignored - excluding it from the results: 
```
➜  nycnode-site git:(master) loop pwd

lib
/Users/mateodelnorte/development/nycnode/nycnode-site/lib

node_modules
/Users/mateodelnorte/development/nycnode/nycnode-site/node_modules

test
/Users/mateodelnorte/development/nycnode/nycnode-site/test
```

## On to the Fun Stuff

Neat, so now we can ignore folders that we don't work with directly. Imagine having a folder that contains all your project repositories for work. Wish you could find out how many files are in each? 
```
➜  nycnode git:(master) ✗ loop "find . -path ./node_modules -prune -o -type f  | wc -l"

nycnode-denormalizer
125

nycnode-meetup-ingestor
148

nycnode-site
1106

nycnode-user-ingestor
103

nycnode-youtube-ingestor
81
```

Better yet, what if you're starting a new feature that spans a distributed system composed of many microservices and a site or two? 

```
➜  nycnode git:(master) ✗ loop "git checkout master"

nycnode-denormalizer
Already on 'master'

nycnode-meetup-ingestor
Already on 'master'

nycnode-site
Already on 'master'

nycnode-user-ingestor
Already on 'master'

nycnode-youtube-ingestor
Already on 'master'

➜  nycnode git:(master) ✗ loop "git pull origin master"

nycnode-denormalizer
From github.com:mateodelnorte/nycnode-denormalizer
 * branch            master     -> FETCH_HEAD

nycnode-meetup-ingestor
From github.com:mateodelnorte/nycnode-meetup-ingestor
 * branch            master     -> FETCH_HEAD

nycnode-site
From github.com:mateodelnorte/nycnode-site
 * branch            master     -> FETCH_HEAD

nycnode-user-ingestor
From github.com:mateodelnorte/nycnode-user-ingestor
 * branch            master     -> FETCH_HEAD

nycnode-youtube-ingestor
From github.com:mateodelnorte/nycnode-youtube-ingestor
 * branch            master     -> FETCH_HEAD
 
➜  nycnode git:(master) ✗ loop "git checkout -b feature/my-new-feature"

nycnode-denormalizer
Switched to a new branch 'feature/my-new-feature'

nycnode-meetup-ingestor
Switched to a new branch 'feature/my-new-feature'

nycnode-site
Switched to a new branch 'feature/my-new-feature'

nycnode-user-ingestor
Switched to a new branch 'feature/my-new-feature'

nycnode-youtube-ingestor
Switched to a new branch 'feature/my-new-feature'
```

Now you're ready to code away across your whole system! `loop "git status"` will show you your status across all repos. `loop "git diff"`, `loop "git push origin feature/my-new-feature"`, and other commands all work like you'd think!

## TODO: 
- plugins

---
_Source: https://npm.io/package/loop-things · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
