diff --git a/contribute.py b/contribute.py index 35884eba442f18b505fe45142491aa667e7c6e3b..78803bb5a04b48b411d42d39d9a54bd899360b68 100644 --- a/contribute.py +++ b/contribute.py @@ -2,6 +2,7 @@ import click import datetime import os from distutils.dir_util import copy_tree +from shutil import copyfile @click.command() @click.option('--date', default=datetime.datetime.today().strftime('%Y-%m-%d'), help='Date of the presentation - format: YYYY-MM-DD') @@ -46,18 +47,8 @@ def main(date, name): os.chdir(fullPath) # generate the symlink to the theme - if not os.path.islink('theme'): - os.symlink('../../theme', 'theme') - click.echo(' > Symlink to theme created.') - else: - click.echo(' > Symlink to theme already exists.') - - # generate the symlink to the package.json file - if not os.path.islink('package.json'): - os.symlink('../../theme/package.json', 'package.json') - click.echo(' > Symlink to package.json created.') - else: - click.echo(' > Symlink to package.json already exists.') + createSymlink('../../theme', 'theme') + createSymlink('../../theme/package.json', 'package.json') # copy the contents of the template folder if not os.path.isfile(os.path.join(fullPath, 'slides', 'index.md')): @@ -67,6 +58,21 @@ def main(date, name): click.echo(' > Slide deck already exists.') + # copy the Gruntfile + if not os.path.isfile(os.path.join(fullPath, 'Gruntfile.coffee')): + copyfile(os.path.join(rootDir, 'template', 'Gruntfile.coffee'), os.path.join(fullPath, 'Gruntfile.coffee')) + click.echo(' > Gruntfile copied.') + else: + click.echo(' > Gruntfile already exists.') + + +def createSymlink(src, dst): + if not os.path.islink(dst): + os.symlink(src, dst) + click.echo(' > Symlink to {0} created.' . format(dst)) + else: + click.echo(' > Symlink to {0} already exists.' . format(dst)) + def validateDate(input): """Validate a date string to fit the ISO format"""