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
c341d4b7
Commit
c341d4b7
authored
Jan 28, 2020
by
Jonah Williams
Committed by
Flutter GitHub Bot
Jan 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Discover pubspec.yaml in parent directories (#48548)
parent
3233252c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
2 deletions
+67
-2
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+15
-2
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+52
-0
No files found.
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
c341d4b7
...
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'package:args/args.dart'
;
import
'package:args/command_runner.dart'
;
import
'package:file/file.dart'
;
import
'package:meta/meta.dart'
;
import
'package:quiver/strings.dart'
;
...
...
@@ -707,8 +708,20 @@ abstract class FlutterCommand extends Command<void> {
Future
<
void
>
validateCommand
()
async
{
if
(
_requiresPubspecYaml
&&
!
PackageMap
.
isUsingCustomPackagesPath
)
{
// Don't expect a pubspec.yaml file if the user passed in an explicit .packages file path.
if
(!
globals
.
fs
.
isFileSync
(
'pubspec.yaml'
))
{
throw
ToolExit
(
userMessages
.
flutterNoPubspec
);
// If there is no pubspec in the current directory, look in the parent
// until one can be found.
bool
changedDirectory
=
false
;
while
(!
globals
.
fs
.
isFileSync
(
'pubspec.yaml'
))
{
final
Directory
nextCurrent
=
globals
.
fs
.
currentDirectory
.
parent
;
if
(
nextCurrent
==
null
||
nextCurrent
.
path
==
globals
.
fs
.
currentDirectory
.
path
)
{
throw
ToolExit
(
userMessages
.
flutterNoPubspec
);
}
globals
.
fs
.
currentDirectory
=
nextCurrent
;
changedDirectory
=
true
;
}
if
(
changedDirectory
)
{
globals
.
printStatus
(
'Changing current working directory to:
${globals.fs.currentDirectory.path}
'
);
}
// Validate the current package map only if we will not be running "pub get" later.
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
c341d4b7
...
...
@@ -125,6 +125,58 @@ void main() {
DeviceManager:
()
=>
MockDeviceManager
(),
});
testUsingContext
(
'Walks upward looking for a pubspec.yaml and succeeds if found'
,
()
async
{
globals
.
fs
.
file
(
'pubspec.yaml'
).
createSync
();
globals
.
fs
.
file
(
'.packages'
)
..
createSync
()
..
writeAsStringSync
(
'Not a valid package'
);
globals
.
fs
.
currentDirectory
=
globals
.
fs
.
directory
(
globals
.
fs
.
path
.
join
(
'a'
,
'b'
,
'c'
))
..
createSync
(
recursive:
true
);
final
RunCommand
command
=
RunCommand
();
applyMocksToCommand
(
command
);
try
{
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'run'
,
'--fast-start'
,
'--no-pub'
,
]);
fail
(
'Expect exception'
);
}
catch
(
e
)
{
expect
(
e
,
isInstanceOf
<
ToolExit
>());
}
final
BufferLogger
bufferLogger
=
globals
.
logger
as
BufferLogger
;
expect
(
bufferLogger
.
statusText
,
contains
(
'Changing current working directory to:'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
testUsingContext
(
'Walks upward looking for a pubspec.yaml and exits if missing'
,
()
async
{
globals
.
fs
.
currentDirectory
=
globals
.
fs
.
directory
(
globals
.
fs
.
path
.
join
(
'a'
,
'b'
,
'c'
))
..
createSync
(
recursive:
true
);
final
RunCommand
command
=
RunCommand
();
applyMocksToCommand
(
command
);
try
{
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'run'
,
'--fast-start'
,
'--no-pub'
,
]);
fail
(
'Expect exception'
);
}
catch
(
e
)
{
expect
(
e
,
isInstanceOf
<
ToolExit
>());
expect
(
e
.
toString
(),
contains
(
'No pubspec.yaml file found'
));
}
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
group
(
'run app'
,
()
{
MemoryFileSystem
fs
;
...
...
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