[flutter_tools] fix -n workaround (#86142)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user