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
4b73746a
Unverified
Commit
4b73746a
authored
Aug 12, 2019
by
Jonah Williams
Committed by
GitHub
Aug 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch filesystem exception from flutter create (#38101)
parent
b8484e34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
template.dart
packages/flutter_tools/lib/src/template.dart
+11
-1
template_test.dart
packages/flutter_tools/test/template_test.dart
+30
-0
No files found.
packages/flutter_tools/lib/src/template.dart
View file @
4b73746a
...
...
@@ -4,6 +4,7 @@
import
'package:mustache/mustache.dart'
as
mustache
;
import
'base/common.dart'
;
import
'base/file_system.dart'
;
import
'cache.dart'
;
import
'globals.dart'
;
...
...
@@ -62,13 +63,22 @@ class Template {
Map
<
String
/* relative */
,
String
/* absolute source */
>
_templateFilePaths
;
/// Render the template into [directory].
///
/// May throw a [ToolExit] if the directory is not writable.
int
render
(
Directory
destination
,
Map
<
String
,
dynamic
>
context
,
{
bool
overwriteExisting
=
true
,
bool
printStatusWhenWriting
=
true
,
})
{
destination
.
createSync
(
recursive:
true
);
try
{
destination
.
createSync
(
recursive:
true
);
}
on
FileSystemException
catch
(
err
)
{
printError
(
err
.
toString
());
throwToolExit
(
'Failed to flutter create at
${destination.path}
.'
);
return
0
;
}
int
fileCount
=
0
;
/// Returns the resolved destination path corresponding to the specified
...
...
packages/flutter_tools/test/template_test.dart
0 → 100644
View file @
4b73746a
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/template.dart'
;
import
'package:mockito/mockito.dart'
;
import
'src/common.dart'
;
import
'src/testbed.dart'
;
void
main
(
)
{
Testbed
testbed
;
setUp
(()
{
testbed
=
Testbed
();
});
test
(
'Template.render throws ToolExit when FileSystem exception is raised'
,
()
=>
testbed
.
run
(()
{
final
Template
template
=
Template
(
fs
.
directory
(
'examples'
),
fs
.
currentDirectory
);
final
MockDirectory
mockDirectory
=
MockDirectory
();
when
(
mockDirectory
.
createSync
(
recursive:
true
)).
thenThrow
(
const
FileSystemException
());
expect
(()
=>
template
.
render
(
mockDirectory
,
<
String
,
Object
>{}),
throwsA
(
isInstanceOf
<
ToolExit
>()));
}));
}
class
MockDirectory
extends
Mock
implements
Directory
{}
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