-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
36 lines (31 loc) · 999 Bytes
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Invoke tasks."""
import os
import json
import shutil
from invoke import task
HERE = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(HERE, 'cookiecutter.json'), 'r') as fp:
COOKIECUTTER_SETTINGS = json.load(fp)
COOKIECUTTER_SETTINGS['repo_name'] = COOKIECUTTER_SETTINGS['app_title'].replace(' ','').lower()
COOKIE = os.path.join(HERE, COOKIECUTTER_SETTINGS['repo_name'])
@task
def build(ctx):
"""Build the cookiecutter."""
ctx.run('cookiecutter {0} --no-input'.format(HERE))
@task
def clean(ctx):
"""Clean out generated cookiecutter."""
print(COOKIE)
if os.path.exists(COOKIE):
shutil.rmtree(COOKIE)
print('Removed {0}'.format(COOKIE))
else:
print('App directory does not exist. Skipping.')
@task(pre=[clean, build])
def test(ctx):
"""Run lint commands and tests."""
os.chdir(COOKIE)
ctx.run('pip install -e ."[test]"', echo=True)
ctx.run('pytest', echo=True)