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
13382f41
Unverified
Commit
13382f41
authored
Jul 13, 2019
by
Zachary Anderson
Committed by
GitHub
Jul 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Catch a yaml parse failure during project creation (#36105)
parent
aa6cc071
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
project.dart
packages/flutter_tools/lib/src/project.dart
+10
-2
project_test.dart
packages/flutter_tools/test/project_test.dart
+22
-2
No files found.
packages/flutter_tools/lib/src/project.dart
View file @
13382f41
...
@@ -16,6 +16,7 @@ import 'bundle.dart' as bundle;
...
@@ -16,6 +16,7 @@ import 'bundle.dart' as bundle;
import
'cache.dart'
;
import
'cache.dart'
;
import
'desktop.dart'
;
import
'desktop.dart'
;
import
'flutter_manifest.dart'
;
import
'flutter_manifest.dart'
;
import
'globals.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/plist_utils.dart'
as
plist
;
import
'ios/plist_utils.dart'
as
plist
;
import
'ios/xcodeproj.dart'
as
xcode
;
import
'ios/xcodeproj.dart'
as
xcode
;
...
@@ -177,9 +178,16 @@ class FlutterProject {
...
@@ -177,9 +178,16 @@ class FlutterProject {
/// Completes with an empty [FlutterManifest], if the file does not exist.
/// Completes with an empty [FlutterManifest], if the file does not exist.
/// Completes with a ToolExit on validation error.
/// Completes with a ToolExit on validation error.
static
FlutterManifest
_readManifest
(
String
path
)
{
static
FlutterManifest
_readManifest
(
String
path
)
{
final
FlutterManifest
manifest
=
FlutterManifest
.
createFromPath
(
path
);
FlutterManifest
manifest
;
if
(
manifest
==
null
)
try
{
manifest
=
FlutterManifest
.
createFromPath
(
path
);
}
on
YamlException
catch
(
e
)
{
printStatus
(
'Error detected in pubspec.yaml:'
,
emphasis:
true
);
printError
(
'
$e
'
);
}
if
(
manifest
==
null
)
{
throwToolExit
(
'Please correct the pubspec.yaml file at
$path
'
);
throwToolExit
(
'Please correct the pubspec.yaml file at
$path
'
);
}
return
manifest
;
return
manifest
;
}
}
...
...
packages/flutter_tools/test/project_test.dart
View file @
13382f41
...
@@ -40,7 +40,19 @@ void main() {
...
@@ -40,7 +40,19 @@ void main() {
expect
(
expect
(
()
=>
FlutterProject
.
fromDirectory
(
directory
),
()
=>
FlutterProject
.
fromDirectory
(
directory
),
throwsA
(
isInstanceOf
<
Exception
>()),
throwsA
(
isInstanceOf
<
ToolExit
>()),
);
});
testInMemory
(
'fails on pubspec.yaml parse failure'
,
()
async
{
final
Directory
directory
=
fs
.
directory
(
'myproject'
);
directory
.
childFile
(
'pubspec.yaml'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
parseErrorPubspec
);
expect
(
()
=>
FlutterProject
.
fromDirectory
(
directory
),
throwsA
(
isInstanceOf
<
ToolExit
>()),
);
);
});
});
...
@@ -52,7 +64,7 @@ void main() {
...
@@ -52,7 +64,7 @@ void main() {
expect
(
expect
(
()
=>
FlutterProject
.
fromDirectory
(
directory
),
()
=>
FlutterProject
.
fromDirectory
(
directory
),
throwsA
(
isInstanceOf
<
Exception
>()),
throwsA
(
isInstanceOf
<
ToolExit
>()),
);
);
});
});
...
@@ -575,6 +587,14 @@ flutter:
...
@@ -575,6 +587,14 @@ flutter:
invalid:
invalid:
'''
;
'''
;
String
get
parseErrorPubspec
=>
'''
name: hello
# Whitespace is important.
flutter:
something:
something_else:
'''
;
String
projectFileWithBundleId
(
String
id
,
{
String
qualifier
})
{
String
projectFileWithBundleId
(
String
id
,
{
String
qualifier
})
{
return
'''
return
'''
97C147061CF9000F007C117D /* Debug */ = {
97C147061CF9000F007C117D /* Debug */ = {
...
...
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