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
bf248fad
Unverified
Commit
bf248fad
authored
Jan 28, 2021
by
Jenn Magder
Committed by
GitHub
Jan 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow 'flutter create' in dev and example directories (#74932)
parent
234952cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
create_base.dart
packages/flutter_tools/lib/src/commands/create_base.dart
+10
-4
create_test.dart
...tter_tools/test/commands.shard/permeable/create_test.dart
+25
-0
No files found.
packages/flutter_tools/lib/src/commands/create_base.dart
View file @
bf248fad
...
...
@@ -249,10 +249,16 @@ abstract class CreateBase extends FlutterCommand {
@protected
void
validateProjectDir
({
bool
overwrite
=
false
})
{
if
(
globals
.
fs
.
path
.
isWithin
(
flutterRoot
,
projectDirPath
))
{
throwToolExit
(
'Cannot create a project within the Flutter SDK. '
"Target directory '
$projectDirPath
' is within the Flutter SDK at '
$flutterRoot
'."
,
exitCode:
2
);
// Make exception for dev and examples to facilitate example project development.
final
String
examplesDirectory
=
globals
.
fs
.
path
.
join
(
flutterRoot
,
'examples'
);
final
String
devDirectory
=
globals
.
fs
.
path
.
join
(
flutterRoot
,
'dev'
);
if
(!
globals
.
fs
.
path
.
isWithin
(
examplesDirectory
,
projectDirPath
)
&&
!
globals
.
fs
.
path
.
isWithin
(
devDirectory
,
projectDirPath
))
{
throwToolExit
(
'Cannot create a project within the Flutter SDK. '
"Target directory '
$projectDirPath
' is within the Flutter SDK at '
$flutterRoot
'."
,
exitCode:
2
);
}
}
// If the destination directory is actually a file, then we refuse to
...
...
packages/flutter_tools/test/commands.shard/permeable/create_test.dart
View file @
bf248fad
...
...
@@ -186,6 +186,31 @@ void main() {
...
noColorTerminalOverride
,
});
testUsingContext
(
'cannot create a project in flutter root'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
String
flutterBin
=
globals
.
fs
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
globals
.
platform
.
isWindows
?
'flutter.bat'
:
'flutter'
);
final
ProcessResult
exec
=
await
Process
.
run
(
flutterBin
,
<
String
>[
'create'
,
'flutter_project'
,
],
workingDirectory:
Cache
.
flutterRoot
,
);
expect
(
exec
.
exitCode
,
2
);
expect
(
exec
.
stderr
,
contains
(
'Cannot create a project within the Flutter SDK'
));
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
...
noColorTerminalOverride
,
});
testUsingContext
(
'Will create an app project if non-empty non-project directory exists without .metadata'
,
()
async
{
await
projectDir
.
absolute
.
childDirectory
(
'blag'
).
create
(
recursive:
true
);
await
projectDir
.
absolute
.
childDirectory
(
'.idea'
).
create
(
recursive:
true
);
...
...
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