From 0312c30a737d93b6b2a8562ccbc93ae21a4aa89f Mon Sep 17 00:00:00 2001 From: Joe Stanton Date: Fri, 15 May 2015 09:21:38 +0100 Subject: [PATCH] Duplicate the name validation for now --- react-native-cli/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/react-native-cli/index.js b/react-native-cli/index.js index 54b582250..91a1a7469 100755 --- a/react-native-cli/index.js +++ b/react-native-cli/index.js @@ -7,7 +7,6 @@ var fs = require('fs'); var path = require('path'); var spawn = require('child_process').spawn; -var utils = require('../local-cli/generator-utils'); var CLI_MODULE_PATH = function() { return path.resolve( @@ -56,8 +55,19 @@ if (cli) { } } +function validatePackageName(name) { + if (!name.match(/^[$A-Z_][0-9A-Z_$]*$/i)) { + console.error( + '"%s" is not a valid name for a project. Please use a valid identifier ' + + 'name (alphanumeric).', + name + ); + process.exit(1); + } +} + function init(name) { - utils.validatePackageName(name); + validatePackageName(name); var root = path.resolve(name); var projectName = path.basename(root);