From 4d06764d505ec080300fdac7d7731eb2f878b96d Mon Sep 17 00:00:00 2001 From: Devon Carew <devoncarew@gmail.com> Date: Fri, 13 Mar 2015 16:23:34 -0700 Subject: [PATCH] remove project name validation --- lib/src/cli_app.dart | 19 +------------------ lib/src/common.dart | 2 +- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/lib/src/cli_app.dart b/lib/src/cli_app.dart index b02e323..18e7611 100644 --- a/lib/src/cli_app.dart +++ b/lib/src/cli_app.dart @@ -158,12 +158,8 @@ class CliApp { return new Future.error(new ArgError('project directory not empty')); } - // Validate and normalize the project name. + // Normalize the project name. String projectName = path.basename(dir.path); - if (_validateName(projectName) != null) { - logger.stderr(_validateName(projectName)); - return new Future.error(new ArgError(_validateName(projectName))); - } projectName = normalizeProjectName(projectName); if (target == null) { @@ -237,19 +233,6 @@ class CliApp { return JSON.encode(itor.toList()); } - String _validateName(String projectName) { - if (projectName.contains(' ')) { - return "The project name cannot contain spaces."; - } - - if (!projectName.startsWith(new RegExp(r'[A-Za-z]'))) { - return "The project name must start with a letter."; - } - - // Project name is valid. - return null; - } - void _usage(ArgParser argParser) { _out('Stagehand will generate the given application type into the current directory.'); _out(''); diff --git a/lib/src/common.dart b/lib/src/common.dart index 534a8c8..140b632 100644 --- a/lib/src/common.dart +++ b/lib/src/common.dart @@ -40,7 +40,7 @@ List<TemplateFile> decodeConcanenatedData(List<String> data) { * Convert a directory name into a reasonably legal pub package name. */ String normalizeProjectName(String name) { - name = name.replaceAll('-', '_'); + name = name.replaceAll('-', '_').replaceAll(' ', '_'); // Strip any extension (like .dart). if (name.contains('.')) { -- GitLab