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
bb683c4c
Unverified
Commit
bb683c4c
authored
Apr 23, 2020
by
Jonah Williams
Committed by
GitHub
Apr 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] fix package config invalidation (#55420)
parent
240611b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+11
-0
project_file_invalidator_test.dart
...ols/test/general.shard/project_file_invalidator_test.dart
+44
-0
No files found.
packages/flutter_tools/lib/src/run_hot.dart
View file @
bb683c4c
...
...
@@ -1270,6 +1270,17 @@ class ProjectFileInvalidator {
if
(
updatedAt
!=
null
&&
updatedAt
.
isAfter
(
lastCompiled
))
{
invalidatedFiles
.
add
(
packageUri
);
packageConfig
=
await
_createPackageConfig
(
packagesPath
);
// The frontend_server might be monitoring the package_config.json file,
// Pub should always produce both files.
// TODO(jonahwilliams): remove after https://github.com/flutter/flutter/issues/55249
if
(
_fileSystem
.
path
.
basename
(
packagesPath
)
==
'.packages'
)
{
final
File
packageConfigFile
=
_fileSystem
.
file
(
packagesPath
)
.
parent
.
childDirectory
(
'.dart_tool'
)
.
childFile
(
'package_config.json'
);
if
(
packageConfigFile
.
existsSync
())
{
invalidatedFiles
.
add
(
packageConfigFile
.
uri
);
}
}
}
_logger
.
printTrace
(
...
...
packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart
View file @
bb683c4c
...
...
@@ -5,6 +5,7 @@
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/convert.dart'
;
import
'package:flutter_tools/src/run_hot.dart'
;
import
'package:package_config/package_config.dart'
;
...
...
@@ -80,6 +81,49 @@ void main() {
);
});
testWithoutContext
(
'Picks up changes to the .packages file and updates package_config.json'
', asyncScanning:
$asyncScanning
'
,
()
async
{
final
DateTime
past
=
DateTime
.
now
().
subtract
(
const
Duration
(
seconds:
1
));
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
PackageConfig
packageConfig
=
PackageConfig
.
empty
;
final
ProjectFileInvalidator
projectFileInvalidator
=
ProjectFileInvalidator
(
fileSystem:
fileSystem
,
platform:
FakePlatform
(),
logger:
BufferLogger
.
test
(),
);
fileSystem
.
file
(
'.packages'
)
.
writeAsStringSync
(
'
\n
'
);
fileSystem
.
file
(
'.dart_tool/package_config.json'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
json
.
encode
(<
String
,
Object
>{
'configVersion'
:
2
,
'packages'
:
<
Object
>[],
}));
final
InvalidationResult
invalidationResult
=
await
projectFileInvalidator
.
findInvalidated
(
lastCompiled:
null
,
urisToMonitor:
<
Uri
>[],
packagesPath:
'.packages'
,
asyncScanning:
asyncScanning
,
packageConfig:
packageConfig
,
);
expect
(
invalidationResult
.
uris
,
isEmpty
);
fileSystem
.
file
(
'.packages'
).
setLastModifiedSync
(
DateTime
.
now
());
final
InvalidationResult
secondInvalidation
=
await
projectFileInvalidator
.
findInvalidated
(
lastCompiled:
past
,
urisToMonitor:
<
Uri
>[],
packagesPath:
'.packages'
,
asyncScanning:
asyncScanning
,
packageConfig:
packageConfig
,
);
expect
(
secondInvalidation
.
uris
,
unorderedEquals
(<
Uri
>[
Uri
.
parse
(
'.packages'
),
Uri
.
parse
(
'.dart_tool/package_config.json'
),
]));
});
testWithoutContext
(
'Picks up changes to the .packages file and updates PackageConfig'
', asyncScanning:
$asyncScanning
'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
...
...
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