forked from cookiecutter-flask/cookiecutter-flask
-
Notifications
You must be signed in to change notification settings - Fork 19
/
tasks.py
28 lines (23 loc) · 758 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import shutil
from invoke import task, run
HERE = os.path.abspath(os.path.dirname(__file__))
# Match default value of app_name from cookiecutter.json
COOKIE = os.path.join(HERE, 'myflaskapp')
REQUIREMENTS = os.path.join(COOKIE, 'requirements', 'dev.txt')
@task
def build():
run('cookiecutter {0} --no-input'.format(HERE))
@task
def clean():
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():
run('pip install -r {0}'.format(REQUIREMENTS), echo=True)
run('python {0} test'.format(os.path.join(COOKIE, 'manage.py')), echo=True)