Skip to content

Instantly share code, notes, and snippets.

@chernjie
Last active February 7, 2021 22:41
Show Gist options
  • Select an option

  • Save chernjie/46983c4bc7c07b77014a5ae60065ca1a to your computer and use it in GitHub Desktop.

Select an option

Save chernjie/46983c4bc7c07b77014a5ae60065ca1a to your computer and use it in GitHub Desktop.

Revisions

  1. chernjie revised this gist Feb 7, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npmr
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ for-each-args () {

    for-each-package() {

    for i in $(git ls-files | grep package.json | xargs -n1 dirname)
    for i in $(git ls-files --recurse-submodules | grep package.json | xargs -n1 dirname)
    do
    cd $i > /dev/null
    npm $@ &
  2. chernjie revised this gist Nov 13, 2019. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion npmr
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,18 @@
    #!/usr/bin/env bash

    # Like `npm`, but executes the command in nested sub-directories within
    # your current git repository
    #
    # @author CJ <lim@chernjie.com>

    # Example:
    #
    # $ npmr ls lodash # List installed packages in nested node packages
    #
    # $ npmr i # install node modules recursively

    for-each-args () {

    local _command=$1
    shift

    @@ -13,6 +25,7 @@ for-each-args () {
    }

    for-each-package() {

    for i in $(git ls-files | grep package.json | xargs -n1 dirname)
    do
    cd $i > /dev/null
    @@ -29,4 +42,4 @@ case $1 in

    *) for-each-package $@ ;;

    esac
    esac
  3. chernjie revised this gist Nov 13, 2019. 2 changed files with 32 additions and 35 deletions.
    35 changes: 0 additions & 35 deletions npm.sh
    Original file line number Diff line number Diff line change
    @@ -1,35 +0,0 @@
    #!/usr/bin/env bash

    npm-install () {
    for i in $(git ls-files | grep package.json | xargs -n1 dirname)
    do
    cd $i > /dev/null
    npm install $@ &
    cd - > /dev/null
    done

    wait
    }

    npm-ls () {
    for i in $(git ls-files | grep package.json | xargs -n1 dirname)
    do
    cd $i > /dev/null
    npm list $@ &
    cd - > /dev/null
    done

    wait

    for i in $@
    do
    npm info $i &
    done

    wait
    }

    case $1 in
    i|install|add) shift; npm-install $@;;
    ls|la|ll|list) shift; npm-ls $@;;
    esac
    32 changes: 32 additions & 0 deletions npmr
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/usr/bin/env bash

    for-each-args () {
    local _command=$1
    shift

    for i in $@
    do
    npm $_command $i &
    done

    wait
    }

    for-each-package() {
    for i in $(git ls-files | grep package.json | xargs -n1 dirname)
    do
    cd $i > /dev/null
    npm $@ &
    cd - > /dev/null
    done

    wait
    }

    case $1 in

    info) for-each-args $@ ;;

    *) for-each-package $@ ;;

    esac
  4. chernjie revised this gist Nov 12, 2019. 2 changed files with 35 additions and 17 deletions.
    35 changes: 35 additions & 0 deletions npm.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/usr/bin/env bash

    npm-install () {
    for i in $(git ls-files | grep package.json | xargs -n1 dirname)
    do
    cd $i > /dev/null
    npm install $@ &
    cd - > /dev/null
    done

    wait
    }

    npm-ls () {
    for i in $(git ls-files | grep package.json | xargs -n1 dirname)
    do
    cd $i > /dev/null
    npm list $@ &
    cd - > /dev/null
    done

    wait

    for i in $@
    do
    npm info $i &
    done

    wait
    }

    case $1 in
    i|install|add) shift; npm-install $@;;
    ls|la|ll|list) shift; npm-ls $@;;
    esac
    17 changes: 0 additions & 17 deletions npmls.sh
    Original file line number Diff line number Diff line change
    @@ -1,17 +0,0 @@
    #!/usr/bin/env bash

    for i in $(git ls-files | grep package.json | xargs -n1 dirname)
    do
    cd $i > /dev/null
    npm ls $@ &
    cd - > /dev/null
    done

    wait

    for i in $@
    do
    npm info $i &
    done

    wait
  5. chernjie revised this gist Aug 14, 2019. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions npmls.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/usr/bin/env bash

    for i in $(git ls-files | grep package.json | xargs -n1 dirname)
    do
    cd $i > /dev/null
    npm ls $@ &
    cd - > /dev/null
    done

    wait

    for i in $@
    do
    npm info $i &
    done

    wait
  6. chernjie created this gist Sep 9, 2013.