All Projects → therealklanni → Git Guppy

therealklanni / Git Guppy

Licence: mit
Simple git-hook integration for your gulp workflows.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Git Guppy

Buddycss
The framework for people who love coding!
Stars: ✭ 89 (-15.24%)
Mutual labels:  gulp
Angular Material Dashboard
Angular admin dashboard with material design
Stars: ✭ 1,321 (+1158.1%)
Mutual labels:  gulp
Wordpressify
🎈 A build system designed to automate your WordPress development workflow.
Stars: ✭ 1,374 (+1208.57%)
Mutual labels:  gulp
Gulp Ngmin
[DEPRECATED] Pre-minify AngularJS apps with ngmin
Stars: ✭ 89 (-15.24%)
Mutual labels:  gulp
Tars Cli
CLI for TARS
Stars: ✭ 92 (-12.38%)
Mutual labels:  gulp
Simulador Rendafixa
Simulador de Renda Fixa Pré e Pós
Stars: ✭ 96 (-8.57%)
Mutual labels:  gulp
Generator Fountain Angular2
Yeoman 'fountain' generator to start a webapp with Angular 2
Stars: ✭ 84 (-20%)
Mutual labels:  gulp
Gulp Flatten
Gulp plugin: remove or replace relative paths for files
Stars: ✭ 102 (-2.86%)
Mutual labels:  gulp
Npm Pipeline Rails
Use npm as part of your Rails asset pipeline
Stars: ✭ 93 (-11.43%)
Mutual labels:  gulp
Gulp Ftp
[DEPRECATED] Upload files to an FTP-server
Stars: ✭ 100 (-4.76%)
Mutual labels:  gulp
Css Flags
A collection of pure CSS flags, all single divs.
Stars: ✭ 90 (-14.29%)
Mutual labels:  gulp
Pug Sass Boilerplate Starter Kit
A Front-end template for building web apps or sites using Pug(Jade) and Sass
Stars: ✭ 92 (-12.38%)
Mutual labels:  gulp
React Tsx Starter
Universal/Isomorphic React TypeScript Starter Project
Stars: ✭ 97 (-7.62%)
Mutual labels:  gulp
Gulp Pure Start
Start your project with 'Gulp Pure Start' easily than ever!
Stars: ✭ 89 (-15.24%)
Mutual labels:  gulp
Nandomoreira Jekyll Theme
💎 My old website in Jekyll and Gulpjs
Stars: ✭ 101 (-3.81%)
Mutual labels:  gulp
Gulp Pug Sass Seed
🍹 A Pug and Sass starter project using gulp for task automation.
Stars: ✭ 84 (-20%)
Mutual labels:  gulp
Generator Fountain Angular1
Yeoman 'fountain' generator to start a webapp with Angular 1
Stars: ✭ 95 (-9.52%)
Mutual labels:  gulp
Bootstrap 4 Sass Gulp 4 Boilerplate
A Bootstrap 4.5.2 boilerplate with font-awesome, sass, gulp 4 tasks
Stars: ✭ 103 (-1.9%)
Mutual labels:  gulp
Frontie Webpack
Front-end Boilerplate | Gulp 4 + Webpack 4 + Babel + ITCSS Architecture + BEM Methodology + Twig.js
Stars: ✭ 102 (-2.86%)
Mutual labels:  gulp
Slimjim
SlimJim is a simple auto update script utilizing Slim (a PHP micro-framework), incron (inotify cron system), and GitHub/BitBucket post-receive-hook
Stars: ✭ 98 (-6.67%)
Mutual labels:  git-hooks

Travis npm npm semantic-release Beerpay

git-guppy

guppy

Simple git-hook integration for your gulp workflows.

guppy streamlines and extends your git-hooks by integrating them with your gulp workflow. This enables you to have gulp tasks that run when triggered by a git-hook, which means you can do cool things like abort a commit if your tests are failing. Git-hooks can now be managed through npm, allowing them to automatically be installed and updated. And because they integrate with gulp, it's easy to modify the workflow and even combine hooks with your other gulp tasks.

guppy leverages these powerful existing systems as its backbone, allowing guppy (and therefore your git-hooks) to remain as simple and lightweight as possible through interfaces you're already familiar with.

A git-hook that lint-checks your code and makes sure your unit tests pass before committing could be as simple as

gulp.task('pre-commit', ['lint', 'unit']);

Install

npm i git-guppy --save-dev

Usage

Git integration

Automatic!

The actual scripts that git will run to trigger guppy's hooks will be automatically installed to your .git/hooks/ directory. These are just a wrapper for invoking the gulp tasks that guppy registers.

Typically, a workflow can be added to your gulp tasks via a guppy-hook. A guppy-hook is like a git-hook preconfigured for specific gulp workflows.

You can install guppy-hooks via npm just like any other package. For every valid git-hook name, there exists a "guppy-[hookname]" package that automatically installs the related hook to your .git/hooks dir, e.g. "guppy-pre-commit" or "guppy-post-update". Just add the guppy-hook you need as a dev-dependency in your project.

Search "guppy-hook" on npm to find all guppy-hook packages. Or run npm search guppy-hook from the commandline.

gulp integration

⚠️ Stop! If you are using a guppy-hook package, refer to the documentation for that package. You do not need the steps below unless you are adding custom guppy integration to your gulpfile or authoring your own guppy-hook package.

guppy exposes a few simple methods to help you superpower your git-hooks with gulp tasks.

Before you dive in, initialize guppy by passing in your gulp reference:

var gulp = require('gulp');
var guppy = require('git-guppy')(gulp);

Then simply define some gulp tasks in your gulpfile.js whose names match whichever git-hooks you want to be triggerable by git.

gulp.task('pre-commit', function () {
  // see below
});

Note: if you are working directly with guppy rather than installing a guppy-hook you will need to manually install the associated git-hooks using the guppy-cli commandline tool.

guppy.src(hookName)

Supported hooks: applypatch-msg, commit-msg, pre-applypatch, pre-commit, prepare-commit-msg

Pass in the name of the desired git-hook and get back the related filenames. This allows you to work with the source file directly, for example to modify a commit-msg programmatically or lint changed files.

Note for pre-commit and pre-applypatch this will give you the working-copy, not the indexed (staged) changes. If you want the indexed changes, use guppy.stream() instead.

// contrived example
gulp.task('pre-commit', function () {
  return gulp.src(guppy.src('pre-commit'))
    .pipe(gulpFilter(['*.js']))
    .pipe(jshint())
    .pipe(jshint.reporter(stylish))
    .pipe(jshint.reporter('fail'));
});

guppy.src(hookName[, fn])

Supported hooks: all

If you pass the optional fn argument, it will be passed to gulp.task() as the task callback, but the first argument will be the related filenames (or null, if none) and a second optional argument may also be supplied (when applicable) with any additional arguments received from the git-hook as an array. gulp will provide its callback as the last argument.

// less contrived example
gulp.task('pre-commit', guppy.src('pre-commit', function (filesBeingCommitted) {
  return gulp.src(filesBeingCommitted)
    .pipe(gulpFilter(['*.js']))
    .pipe(jshint())
    .pipe(jshint.reporter(stylish))
    .pipe(jshint.reporter('fail'));
}));

// another contrived example
gulp.task('pre-push', guppy.src('pre-push', function (files, extra, cb) {
  var branch = execSync('git rev-parse --abbrev-ref HEAD');

  if (branch === 'master') {
    cb('Don\'t push master!')
  } else {
    cb();
  }
}));

guppy.stream(hookName[, options])

Supported hooks: applypatch-msg, commit-msg, pre-applypatch, pre-commit, prepare-commit-msg

Pass in the name of the git-hook to produce a stream of the related files. You can pass options as a second argument, please refer to the docs for gulp.src for more information on available options.

Note that depending on the git-hook, you may be acting on files that differ from your working copy, such as those staged for commit (as with 'pre-commit' for example), rather than the working copy. If you need to act on the working-copy files, use guppy.src() instead.

gulp.task('pre-commit', function () {
  return guppy.stream('pre-commit')
    .pipe(gulpFilter(['*.js']))
    .pipe(jshint())
    .pipe(jshint.reporter(stylish))
    .pipe(jshint.reporter('fail'));
});

Additional notes

For many git-hooks there are no files associated, so for those it makes sense to only add other gulp tasks as dependencies to invoke a workflow, however some will still receive some arguments (passed in by guppy.src() when used as a callback) for more advanced use cases.

gulp.task('post-checkout', ['lint']);

Writing guppy-hooks

stay tuned

For details on what arguments each git-hook receives and what result a non-zero exit status would have, check the git-scm docs.

Author

Kevin Lanni

License

MIT © Kevin Lanni

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].