Unverified Commit 9d70d9d5 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] fix -n workaround (#86142)

parent 75f6d03b
......@@ -47,8 +47,8 @@ class FormatCommand extends FlutterCommand {
} else {
command.addAll(<String>[
for (String arg in argResults.rest)
if (arg == '--dry-run')
'--output=show'
if (arg == '--dry-run' || arg == '-n')
'--output=none'
else
arg
]);
......
......@@ -59,6 +59,23 @@ void main() {
expect(shouldNotFormatted, nonFormatted);
});
testUsingContext('dry-run with -n', () async {
final String projectPath = await createProject(tempDir);
final File srcFile = globals.fs.file(
globals.fs.path.join(projectPath, 'lib', 'main.dart'));
final String nonFormatted = srcFile.readAsStringSync().replaceFirst(
'main()', 'main( )');
srcFile.writeAsStringSync(nonFormatted);
final FormatCommand command = FormatCommand(verboseHelp: false);
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['format', '-n', srcFile.path]);
final String shouldNotFormatted = srcFile.readAsStringSync();
expect(shouldNotFormatted, nonFormatted);
});
testUsingContext('dry-run with set-exit-if-changed', () async {
final String projectPath = await createProject(tempDir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment