• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    JavaScript
  • Created almost 8 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

loop through commands in fun and amazing ways!

loop

Build Status

loop 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, 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 --include-pattern 'regexp'                     - execute a command against all child dirs that match the regular expression
      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 --exclude-pattern 'regexp'                     - execute a command against all child dirs, excluding directories that match the regular expression
      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

Basic Usage

loop 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

More Repositories

1

meta

tool for turning many repos into a meta repo. why choose many repos or a monolithic repo, when you can have both with a meta repo?
JavaScript
2,026
star
2

servicebus

Simple service bus for sending events between processes using amqp.
JavaScript
420
star
3

sourced

Tiny framework for building models with the event sourcing pattern (events and snapshots).
JavaScript
284
star
4

forecast.io

wrapper for the forecast.io API
JavaScript
117
star
5

sourced-repo-mongo

mongo data store and repository for sourced-style event sourcing models
JavaScript
55
star
6

coinbase

wrapper for the coinbase bitcoin wallet & exchange API
JavaScript
48
star
7

meta-git

git plugin for meta
JavaScript
23
star
8

servicebus-retry

JavaScript
18
star
9

mockrequire

Simple module for mocking required dependencies. Works with any testing suite.
JavaScript
17
star
10

node-paypal-masspayments

Node PayPal Mass Payment NVM
JavaScript
14
star
11

servicebus-register-handlers

JavaScript
11
star
12

microsvc

tiny reusable framework for building microservices with messaging and rest
JavaScript
11
star
13

servicebus-trace

servicebus middleware to publish message receipt information to a central store, for message tracking and tracing purposes.
JavaScript
10
star
14

filecoin-lotus-docker

Dockerfile
9
star
15

meta-npm

npm plugin for meta
JavaScript
8
star
16

meta-yarn

yarn plugin for meta
JavaScript
6
star
17

node_hands_on-unit_testing

6
star
18

meta-project

JavaScript
6
star
19

july3rd

6
star
20

SeattleNodejs.SimpleServerWHerokuDeploy

JavaScript
5
star
21

amqp-match

transforms amqp routing keys to regular expressions for more convenient runtime matching
JavaScript
4
star
22

selenium-webdriver-slug

Starter project for getting rolling with Selenium Webdriver and PhantomJS
JavaScript
4
star
23

meta-gh

gh command plugin for meta
JavaScript
3
star
24

cconfig

JavaScript
3
star
25

kill-all-node-on-windows

JavaScript
3
star
26

meta-init

plugin for initializing new meta repositories
JavaScript
2
star
27

sample-service

JavaScript
2
star
28

servicebus-message-domain

JavaScript
2
star
29

gitslave

fork of gitslave from http://gitslave.sourceforge.net/ modified to work with current versions of git
Perl
2
star
30

meta-exec

exec plugin for meta
JavaScript
2
star
31

llog

JavaScript
2
star
32

find-file-recursively-up

returns the path at which a provided filename exists, checking the current directory and any parent folders recursively up.
JavaScript
2
star
33

pidler

simple module to create process pids
JavaScript
1
star
34

meta-loop

helper function to loop-exec in a meta repository and all child repositories
JavaScript
1
star
35

sample-site

CSS
1
star
36

microsvc-slave

JavaScript
1
star
37

objectify-folder

return all non index.js modules in a folder as a single object
JavaScript
1
star
38

thenodejsmeetup.com

JavaScript
1
star
39

servicebus-rabbitmq

rabbitmq bus provider for servicebus
JavaScript
1
star
40

get-meta-file

JavaScript
1
star
41

brb

1
star
42

symlink-meta-dependencies

symlink all of a project's dependencies which appear in the project's .meta file
JavaScript
1
star
43

sourced-queued-repo

JavaScript
1
star
44

google-cloud-run

google cloud run example project with build and deployment helpers
Makefile
1
star
45

find-module-bin

scan known node_modules directories to find installation directory of a particular bin file
JavaScript
1
star
46

microsvc-example

JavaScript
1
star