Created
February 10, 2013 22:38
-
-
Save datacodesolutions/4751361 to your computer and use it in GitHub Desktop.
Sync Composer to App without .git
This file contains hidden or 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/python | |
| # imports | |
| import os, sys, os.path, pprint, tarfile | |
| from subprocess import call | |
| # vars | |
| tarfile_name = 'vendor.tar.gz' | |
| syncdir_source = 'vendor' | |
| syncdir_target = '/Path/To/App' | |
| composer_path = '/usr/local/bin/composer' | |
| # functions | |
| def filtered_files(tarinfo): | |
| directories = tarinfo.name.split('/') | |
| if('.git' in directories): | |
| return None | |
| return tarinfo | |
| # create tar | |
| tar = tarfile.open(tarfile_name, 'w') | |
| tar.add(syncdir_source, filter=filtered_files) | |
| tar.close() | |
| # extract tar | |
| tar = tarfile.open(tarfile_name) | |
| tar.extractall(syncdir_target) | |
| tar.close() | |
| # update autoload | |
| call('cd ' + syncdir_target + ' && ' + composer_path + ' dumpautoload', shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment