validate project names, closes #26, closes #27

This commit is contained in:
Dan Motzenbecker 2015-11-11 23:12:04 -05:00
parent 6f7c2a1d19
commit 7b1fe6998e
1 changed files with 4 additions and 0 deletions

View File

@ -16,6 +16,7 @@ pkgJson = require __dirname + '/package.json'
nodeVersion = pkgJson.engines.node nodeVersion = pkgJson.engines.node
resources = __dirname + '/resources/' resources = __dirname + '/resources/'
validNameRx = /^[A-Z][0-9A-Z]*$/i
camelRx = /([a-z])([A-Z])/g camelRx = /([a-z])([A-Z])/g
projNameRx = /\$PROJECT_NAME\$/g projNameRx = /\$PROJECT_NAME\$/g
projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g
@ -147,6 +148,9 @@ getBundleId = (name) ->
init = (projName, interfaceName) -> init = (projName, interfaceName) ->
if projName.toLowerCase() is 'react' or !projName.match validNameRx
logErr 'Invalid project name. Use an alphanumeric CamelCase name.'
projNameHyph = projName.replace(camelRx, '$1-$2').toLowerCase() projNameHyph = projName.replace(camelRx, '$1-$2').toLowerCase()
projNameUs = toUnderscored projName projNameUs = toUnderscored projName