Skip to content

Instantly share code, notes, and snippets.

@datacodesolutions
Created February 10, 2013 22:38
Show Gist options
  • Select an option

  • Save datacodesolutions/4751361 to your computer and use it in GitHub Desktop.

Select an option

Save datacodesolutions/4751361 to your computer and use it in GitHub Desktop.
Sync Composer to App without .git
#! /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