Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chadrien
Last active December 25, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadrien/6975012 to your computer and use it in GitHub Desktop.
Save chadrien/6975012 to your computer and use it in GitHub Desktop.
Git hooks when using composer/bower/npm
#!/usr/bin/env php
<?php
exec("git diff --name-only {$argv[1]} {$argv[2]}", $changedFiles);
$filesAction = array(
'composer.lock' => 'composer install',
'package.json' => 'npm install',
'bower.json' => 'bower install',
);
foreach ($filesAction as $file => $action) {
if (in_array($file, $changedFiles)) {
passthru($action);
}
}
#!/usr/bin/env php
<?php
exec('git diff --name-only HEAD HEAD~1', $changedFiles);
$filesAction = array(
'composer.lock' => 'composer install',
'package.json' => 'npm install',
'bower.json' => 'bower install',
);
foreach ($filesAction as $file => $action) {
if (in_array($file, $changedFiles)) {
passthru($action);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment