Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Commit

Permalink
ignore things from elm-stuff, create exact-deps if doesnt exist
Browse files Browse the repository at this point in the history
  • Loading branch information
eeue56 committed Mar 30, 2016
1 parent 9a67cfe commit 3f39f1a
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions elm_self_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import sys
import json
import shutil
import os
import errno
import argparse

def copy_package(location, destination):
def copy_package(location, destination, ignorer=None):
shutil.rmtree(destination, ignore_errors=True)
shutil.copytree(location, destination)
shutil.copytree(location, destination, ignore=ignorer)

def package_name(url):
""" get the package name from a github url """
Expand All @@ -21,6 +23,24 @@ def package_name(url):
"user": user
}

def make_elm_stuff_folder(path):
actual_path = '/'.join(path.split('/')[:-1])

try:
os.makedirs(actual_path)
except OSError as e:
if e.errno == errno.EEXIST and os.path.isdir(actual_path):
pass
else:
raise

def gitignores(path):
try:
with open(path) as f:
return [line.strip() for line in f]
except:
return []

def self_publish(package_location, destination=".", quiet=False):
""" package_location should be the local package to install
"""
Expand All @@ -33,6 +53,9 @@ def self_publish(package_location, destination=".", quiet=False):
location=package_location
)

git_ignore_file = "{location}/.gitignore".format(location=package_location)


with open(elm_package_file) as f:
elm_package = json.load(f)

Expand All @@ -48,15 +71,20 @@ def self_publish(package_location, destination=".", quiet=False):
place=place,
version=version,
destination=destination
))
), ignorer=shutil.ignore_patterns(*gitignores(git_ignore_file)))


try:
with open(exact_deps_file) as f:
data = f.read()
package_info = {}

with open(exact_deps_file) as f:
data = f.read()
if data:
package_info = json.loads(data)
except IOError:
package_info = {}

if data:
package_info = json.loads(data)
make_elm_stuff_folder(exact_deps_file)

with open(exact_deps_file, 'w') as f:
package_info[place] = version
Expand Down

0 comments on commit 3f39f1a

Please sign in to comment.