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
8cf20f3b
Unverified
Commit
8cf20f3b
authored
Dec 03, 2019
by
Jonah Williams
Committed by
GitHub
Dec 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont crash on malformed packages.json (#45786)
parent
0ce9206e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
vscode.dart
packages/flutter_tools/lib/src/vscode/vscode.dart
+6
-2
vscode_test.dart
packages/flutter_tools/test/general.shard/vscode_test.dart
+28
-0
No files found.
packages/flutter_tools/lib/src/vscode/vscode.dart
View file @
8cf20f3b
...
@@ -224,8 +224,12 @@ class VsCode {
...
@@ -224,8 +224,12 @@ class VsCode {
return
null
;
return
null
;
}
}
final
String
jsonString
=
fs
.
file
(
packageJsonPath
).
readAsStringSync
();
final
String
jsonString
=
fs
.
file
(
packageJsonPath
).
readAsStringSync
();
try
{
final
Map
<
String
,
dynamic
>
jsonObject
=
castStringKeyedMap
(
json
.
decode
(
jsonString
));
final
Map
<
String
,
dynamic
>
jsonObject
=
castStringKeyedMap
(
json
.
decode
(
jsonString
));
return
jsonObject
[
'version'
]
as
String
;
return
jsonObject
[
'version'
]
as
String
;
}
on
FormatException
{
return
null
;
}
}
}
}
}
...
...
packages/flutter_tools/test/general.shard/vscode_test.dart
0 → 100644
View file @
8cf20f3b
// 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:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/version.dart'
;
import
'package:flutter_tools/src/vscode/vscode.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
void
main
(
)
{
testUsingContext
(
'VsCode.fromDirectory does not crash when packages.json is malformed'
,
()
{
// Create invalid JSON file.
fs
.
file
(
fs
.
path
.
join
(
''
,
'resources'
,
'app'
,
'package.json'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'{'
);
final
VsCode
vsCode
=
VsCode
.
fromDirectory
(
''
,
''
);
expect
(
vsCode
.
version
,
Version
.
unknown
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
}
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