Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save realyze/f2a53a4119f955ff63337af72ebbc5cf to your computer and use it in GitHub Desktop.

Select an option

Save realyze/f2a53a4119f955ff63337af72ebbc5cf to your computer and use it in GitHub Desktop.

Revisions

  1. realyze revised this gist Jul 25, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion yarn-post-merge-and-checkout-hooks.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ cd ~/.git-templates/hooks
    cat >post-checkout <<'EOL'
    changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
    check_run() {
    echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
    echo "$changed_files" | grep -E --quiet "$1" && eval "$2" || true
    }
    # yarn all the things if yarn.lock has changed
    check_run "web/yarn.lock" "cd web && yarn"
  2. realyze renamed this gist Jul 25, 2018. 1 changed file with 0 additions and 0 deletions.
  3. realyze revised this gist Jul 25, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion yarn-composer-post-merge-and-checkout-hooks.sh
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ check_run() {
    echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
    }
    # yarn all the things if yarn.lock has changed
    check_run "web/yarn.lock" "yarn install"
    check_run "web/yarn.lock" "cd web && yarn"
    EOL

    cp post-checkout ./post-merge && cp post-checkout ./post-fetch
  4. realyze revised this gist Jul 25, 2018. 1 changed file with 2 additions and 9 deletions.
    11 changes: 2 additions & 9 deletions yarn-composer-post-merge-and-checkout-hooks.sh
    Original file line number Diff line number Diff line change
    @@ -6,18 +6,11 @@ cd ~/.git-templates/hooks

    cat >post-checkout <<'EOL'
    changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
    check_run() {
    echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
    }
    # `npm install` and `npm prune` if the `package.json` file gets changed
    # to update all the nodejs ( grunt ) dependencies deleting the unused packages (not listed into the `package.json` file)
    check_run package.json "yarn install"
    # `composer install` if the `composer.json` file gets changed
    # to update all the php dependencies
    check_run composer "composer install"
    # yarn all the things if yarn.lock has changed
    check_run "web/yarn.lock" "yarn install"
    EOL

    cp post-checkout ./post-merge && cp post-checkout ./post-fetch
  5. @martinwheeler martinwheeler revised this gist May 25, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion yarn-composer-post-merge-and-checkout-hooks.sh
    Original file line number Diff line number Diff line change
    @@ -20,5 +20,5 @@ check_run package.json "yarn install"
    check_run composer "composer install"
    EOL

    cp post-checkout ./post-merge
    cp post-checkout ./post-merge && cp post-checkout ./post-fetch
    chmod -R a+x .
  6. @martinwheeler martinwheeler created this gist May 25, 2018.
    24 changes: 24 additions & 0 deletions yarn-composer-post-merge-and-checkout-hooks.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #/usr/bin/env bash

    git config --global init.templatedir '~/.git-templates' && \
    mkdir -p ~/.git-templates/hooks && \
    cd ~/.git-templates/hooks

    cat >post-checkout <<'EOL'
    changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
    check_run() {
    echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
    }
    # `npm install` and `npm prune` if the `package.json` file gets changed
    # to update all the nodejs ( grunt ) dependencies deleting the unused packages (not listed into the `package.json` file)
    check_run package.json "yarn install"
    # `composer install` if the `composer.json` file gets changed
    # to update all the php dependencies
    check_run composer "composer install"
    EOL

    cp post-checkout ./post-merge
    chmod -R a+x .