Run lint command when testing the cookiecutter

master
Steven Loria 9 years ago
parent 2a1b0fddca
commit 796d955cda
  1. 17
      tasks.py
  2. 2
      {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py
  3. 2
      {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/extensions.py

@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Invoke tasks."""
import os
import shutil
@ -10,19 +11,31 @@ HERE = os.path.abspath(os.path.dirname(__file__))
COOKIE = os.path.join(HERE, 'myflaskapp')
REQUIREMENTS = os.path.join(COOKIE, 'requirements', 'dev.txt')
@task
def build():
"""Build the cookiecutter."""
run('cookiecutter {0} --no-input'.format(HERE))
@task
def clean():
"""Clean out generated cookiecutter."""
if os.path.exists(COOKIE):
shutil.rmtree(COOKIE)
print('Removed {0}'.format(COOKIE))
else:
print('App directory does not exist. Skipping.')
def _run_manage_command(command):
run('python {0} {1}'.format(os.path.join(COOKIE, 'manage.py'), command), echo=True)
@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)
"""Run lint commands and tests."""
run('pip install -r {0} --ignore-installed'.format(REQUIREMENTS), echo=True)
os.chdir(COOKIE)
_run_manage_command('lint')
_run_manage_command('test')

@ -4,7 +4,7 @@ from flask import Flask, render_template
from {{cookiecutter.app_name}} import public, user
from {{cookiecutter.app_name}}.assets import assets
from {{cookiecutter.app_name}}.extensions import bcrypt, cache, db, debug_toolbar, csrf_protect, login_manager, migrate
from {{cookiecutter.app_name}}.extensions import bcrypt, cache, csrf_protect, db, debug_toolbar, login_manager, migrate
from {{cookiecutter.app_name}}.settings import ProdConfig

@ -3,10 +3,10 @@
from flask_bcrypt import Bcrypt
from flask_cache import Cache
from flask_debugtoolbar import DebugToolbarExtension
from flask_wtf.csrf import CsrfProtect
from flask_login import LoginManager
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from flask_wtf.csrf import CsrfProtect
bcrypt = Bcrypt()
csrf_protect = CsrfProtect()

Loading…
Cancel
Save