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
3da9eee2
Unverified
Commit
3da9eee2
authored
Jun 03, 2022
by
Jesús S Guerrero
Committed by
GitHub
Jun 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] re-use findProjectRoot on flutter command (#104850)
parent
7df7e8ab
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
11 deletions
+26
-11
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+0
-1
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+6
-9
pub_get_test.dart
...tter_tools/test/commands.shard/hermetic/pub_get_test.dart
+20
-1
No files found.
packages/flutter_tools/lib/src/commands/packages.dart
View file @
3da9eee2
...
@@ -58,7 +58,6 @@ class PackagesCommand extends FlutterCommand {
...
@@ -58,7 +58,6 @@ class PackagesCommand extends FlutterCommand {
class
PackagesGetCommand
extends
FlutterCommand
{
class
PackagesGetCommand
extends
FlutterCommand
{
PackagesGetCommand
(
this
.
name
,
this
.
upgrade
)
{
PackagesGetCommand
(
this
.
name
,
this
.
upgrade
)
{
requiresPubspecYaml
();
argParser
.
addFlag
(
'offline'
,
argParser
.
addFlag
(
'offline'
,
negatable:
false
,
negatable:
false
,
help:
'Use cached packages instead of accessing the network.'
,
help:
'Use cached packages instead of accessing the network.'
,
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
3da9eee2
...
@@ -12,6 +12,7 @@ import '../application_package.dart';
...
@@ -12,6 +12,7 @@ import '../application_package.dart';
import
'../base/common.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/context.dart'
;
import
'../base/io.dart'
as
io
;
import
'../base/io.dart'
as
io
;
import
'../base/os.dart'
;
import
'../base/user_messages.dart'
;
import
'../base/user_messages.dart'
;
import
'../base/utils.dart'
;
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
...
@@ -1475,16 +1476,12 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -1475,16 +1476,12 @@ abstract class FlutterCommand extends Command<void> {
// If there is no pubspec in the current directory, look in the parent
// If there is no pubspec in the current directory, look in the parent
// until one can be found.
// until one can be found.
bool
changedDirectory
=
false
;
final
String
?
path
=
findProjectRoot
(
globals
.
fs
,
globals
.
fs
.
currentDirectory
.
path
);
while
(!
globals
.
fs
.
isFileSync
(
'pubspec.yaml'
))
{
if
(
path
==
null
)
{
final
Directory
nextCurrent
=
globals
.
fs
.
currentDirectory
.
parent
;
throwToolExit
(
userMessages
.
flutterNoPubspec
);
if
(
nextCurrent
==
null
||
nextCurrent
.
path
==
globals
.
fs
.
currentDirectory
.
path
)
{
throw
ToolExit
(
userMessages
.
flutterNoPubspec
);
}
}
globals
.
fs
.
currentDirectory
=
nextCurrent
;
if
(
path
!=
globals
.
fs
.
currentDirectory
.
path
)
{
changedDirectory
=
true
;
globals
.
fs
.
currentDirectory
=
path
;
}
if
(
changedDirectory
)
{
globals
.
printStatus
(
'Changing current working directory to:
${globals.fs.currentDirectory.path}
'
);
globals
.
printStatus
(
'Changing current working directory to:
${globals.fs.currentDirectory.path}
'
);
}
}
}
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/pub_get_test.dart
View file @
3da9eee2
...
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
...
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/packages.dart'
;
import
'package:flutter_tools/src/commands/packages.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:test/fake.dart'
;
import
'package:test/fake.dart'
;
...
@@ -77,6 +78,24 @@ void main() {
...
@@ -77,6 +78,24 @@ void main() {
FileSystem:
()
=>
fileSystem
,
FileSystem:
()
=>
fileSystem
,
});
});
testUsingContext
(
'pub get on target directory'
,
()
async
{
fileSystem
.
currentDirectory
.
childDirectory
(
'target'
).
createSync
();
final
Directory
targetDirectory
=
fileSystem
.
currentDirectory
.
childDirectory
(
'target'
);
targetDirectory
.
childFile
(
'pubspec.yaml'
).
createSync
();
final
PackagesGetCommand
command
=
PackagesGetCommand
(
'get'
,
false
);
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
command
);
await
commandRunner
.
run
(<
String
>[
'get'
,
targetDirectory
.
path
]);
final
FlutterProject
rootProject
=
FlutterProject
.
fromDirectory
(
targetDirectory
);
expect
(
rootProject
.
packageConfigFile
.
existsSync
(),
true
);
expect
(
await
rootProject
.
packageConfigFile
.
readAsString
(),
'{"configVersion":2,"packages":[]}'
);
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
pub
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
FileSystem:
()
=>
fileSystem
,
});
testUsingContext
(
"pub get skips example directory if it doesn't contain a pubspec.yaml"
,
()
async
{
testUsingContext
(
"pub get skips example directory if it doesn't contain a pubspec.yaml"
,
()
async
{
fileSystem
.
currentDirectory
.
childFile
(
'pubspec.yaml'
).
createSync
();
fileSystem
.
currentDirectory
.
childFile
(
'pubspec.yaml'
).
createSync
();
fileSystem
.
currentDirectory
.
childDirectory
(
'example'
).
createSync
(
recursive:
true
);
fileSystem
.
currentDirectory
.
childDirectory
(
'example'
).
createSync
(
recursive:
true
);
...
@@ -116,7 +135,7 @@ class FakePub extends Fake implements Pub {
...
@@ -116,7 +135,7 @@ class FakePub extends Fake implements Pub {
bool
shouldSkipThirdPartyGenerator
=
true
,
bool
shouldSkipThirdPartyGenerator
=
true
,
bool
printProgress
=
true
,
bool
printProgress
=
true
,
})
async
{
})
async
{
fileSystem
.
currentDirectory
fileSystem
.
directory
(
directory
)
.
childDirectory
(
'.dart_tool'
)
.
childDirectory
(
'.dart_tool'
)
.
childFile
(
'package_config.json'
)
.
childFile
(
'package_config.json'
)
..
createSync
(
recursive:
true
)
..
createSync
(
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