Skip to content

Commit

Permalink
Duplicate the name validation for now
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeStanton committed May 15, 2015
1 parent 396439b commit 0312c30
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions react-native-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0312c30

Please sign in to comment.