Last active
December 25, 2015 12:19
-
-
Save chadrien/6975012 to your computer and use it in GitHub Desktop.
Git hooks when using composer/bower/npm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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