Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
030f623a
Commit
030f623a
authored
Oct 29, 2016
by
Adam Barth
Committed by
GitHub
Oct 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent `flutter create` from running inside SDK (#6587)
Fixes #6480
parent
02883908
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+15
-8
No files found.
packages/flutter_tools/lib/src/commands/create.dart
View file @
030f623a
...
@@ -91,13 +91,15 @@ class CreateCommand extends FlutterCommand {
...
@@ -91,13 +91,15 @@ class CreateCommand extends FlutterCommand {
String
relativePath
=
path
.
relative
(
dirPath
);
String
relativePath
=
path
.
relative
(
dirPath
);
String
projectName
=
_normalizeProjectName
(
path
.
basename
(
dirPath
));
String
projectName
=
_normalizeProjectName
(
path
.
basename
(
dirPath
));
if
(
_validateProjectDir
(
dirPath
)
!=
null
)
{
String
error
=
_validateProjectDir
(
dirPath
,
flutterRoot:
flutterRoot
);
printError
(
_validateProjectDir
(
dirPath
));
if
(
error
!=
null
)
{
printError
(
error
);
return
1
;
return
1
;
}
}
if
(
_validateProjectName
(
projectName
)
!=
null
)
{
error
=
_validateProjectName
(
projectName
);
printError
(
_validateProjectName
(
projectName
));
if
(
error
!=
null
)
{
printError
(
error
);
return
1
;
return
1
;
}
}
...
@@ -242,17 +244,22 @@ String _validateProjectName(String projectName) {
...
@@ -242,17 +244,22 @@ String _validateProjectName(String projectName) {
/// Return `null` if the project directory is legal. Return a validation message
/// Return `null` if the project directory is legal. Return a validation message
/// if we should disallow the directory name.
/// if we should disallow the directory name.
String
_validateProjectDir
(
String
projectName
)
{
String
_validateProjectDir
(
String
dirPath
,
{
String
flutterRoot
})
{
FileSystemEntityType
type
=
FileSystemEntity
.
typeSync
(
projectName
);
if
(
path
.
isWithin
(
flutterRoot
,
dirPath
))
{
return
"Cannot create a project within the Flutter SDK.
\n
"
"Target directory '
$dirPath
' is within the Flutter SDK at '
$flutterRoot
'."
;
}
FileSystemEntityType
type
=
FileSystemEntity
.
typeSync
(
dirPath
);
if
(
type
!=
FileSystemEntityType
.
NOT_FOUND
)
{
if
(
type
!=
FileSystemEntityType
.
NOT_FOUND
)
{
switch
(
type
)
{
switch
(
type
)
{
case
FileSystemEntityType
.
FILE
:
case
FileSystemEntityType
.
FILE
:
// Do not overwrite files.
// Do not overwrite files.
return
"Invalid project name: '
$
projectName
' - file exists."
;
return
"Invalid project name: '
$
dirPath
' - file exists."
;
case
FileSystemEntityType
.
LINK
:
case
FileSystemEntityType
.
LINK
:
// Do not overwrite links.
// Do not overwrite links.
return
"Invalid project name: '
$
projectName
' - refers to a link."
;
return
"Invalid project name: '
$
dirPath
' - refers to a link."
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment