Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use relative path instead of absolute when running packages get #919

Merged
merged 13 commits into from
Dec 18, 2023
Merged
8 changes: 7 additions & 1 deletion lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ class Flutter {
bool recursive = false,
Set<String> ignore = const {},
}) async {
final initialCwd = cwd;

await _runCommand(
cmd: (cwd) async {
final relativePath = p.relative(cwd, from: initialCwd);
final path =
relativePath == '.' ? '.' : '.${p.context.separator}$relativePath';

final installProgress = logger.progress(
'Running "flutter packages get" in $cwd',
'Running "flutter packages get" in $path ',
);

try {
Expand Down
11 changes: 9 additions & 2 deletions test/src/cli/flutter_cli_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,30 @@ void main() {
),
runProcess: process.run,
).whenComplete(() {
final nestedRelativePath =
p.relative(nestedDirectory.path, from: tempDirectory.path);
verify(() {
logger.progress(
any(
that: contains(
'Running "flutter packages get" in '
'${nestedDirectory.path}',
'.${p.context.separator}$nestedRelativePath',
),
),
);
}).called(1);

verifyNever(() {
final ignoredRelativePath = p.relative(
ignoredDirectory.path,
from: tempDirectory.path,
);

logger.progress(
any(
that: contains(
'Running "flutter packages get" in '
'${ignoredDirectory.path}',
'./$ignoredRelativePath',
alestiago marked this conversation as resolved.
Show resolved Hide resolved
),
),
);
Expand Down
11 changes: 9 additions & 2 deletions test/src/commands/packages/commands/get_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,17 @@ void main() {
tempDirectory.path,
],
);

final relativePathPrefix = '.${path.context.separator}';

expect(result, equals(ExitCode.success.code));
verify(() {
logger.progress(
any(
that: contains(
'Running "flutter packages get" in ${directoryA.path}',
'Running "flutter packages get" in '
'$relativePathPrefix'
'${path.relative(directoryA.path, from: tempDirectory.path)}',
),
),
);
Expand All @@ -356,7 +361,9 @@ void main() {
logger.progress(
any(
that: contains(
'Running "flutter packages get" in ${directoryB.path}',
'Running "flutter packages get" in '
'$relativePathPrefix'
'${path.relative(directoryB.path, from: tempDirectory.path)}',
),
),
);
Expand Down