@@ -13,7 +13,7 @@ const stringifyAuthor = require('stringify-author')
1313const { guessEmail, guessAuthor, guessGitHubUsername} = require ( 'conjecture' )
1414const validatePackageName = require ( 'validate-npm-package-name' )
1515
16- const TEMPLATE_REPO_URL = 'https://github.com/probot/template.git'
16+ const DEFAULT_TEMPLATE = 'https://github.com/probot/template.git'
1717
1818program
1919 . usage ( '[options] [destination]' )
@@ -27,10 +27,18 @@ program
2727 . option ( '-u, --user <username>' , 'GitHub username or org (repo owner)' )
2828 . option ( '-r, --repo <repo-name>' , 'Repository name' )
2929 . option ( '--overwrite' , 'Overwrite existing files' , false )
30- . option ( '--template <template-url>' , 'URL of custom template' ,
31- TEMPLATE_REPO_URL )
30+ . option ( '--template <template-url>' , 'URL or name of custom template' , getTemplateRepository , DEFAULT_TEMPLATE )
31+ . option ( '--typescript' , 'Use the TypeScript template' , ( ) => program . emit ( 'option:template' , 'typescript' ) )
3232 . parse ( process . argv )
3333
34+ function getTemplateRepository ( value ) {
35+ if ( / ^ [ \w - ] + $ / . test ( value ) ) {
36+ return `https://github.com/probot/template-${ value } .git`
37+ } else {
38+ return value
39+ }
40+ }
41+
3442const destination = program . args . length
3543 ? path . resolve ( process . cwd ( ) , program . args . shift ( ) )
3644 : process . cwd ( )
@@ -116,6 +124,7 @@ inquirer.prompt(prompts)
116124 url : answers . homepage
117125 } )
118126 answers . year = new Date ( ) . getFullYear ( )
127+
119128 return scaffold ( program . template , destination , answers , {
120129 overwrite : Boolean ( program . overwrite )
121130 } )
0 commit comments