@@ -8,6 +8,7 @@ import 'package:args/command_runner.dart';
88import 'package:file/file.dart' ;
99import 'package:file/memory.dart' ;
1010import 'package:flutter_plugin_tools/src/common/core.dart' ;
11+ import 'package:flutter_plugin_tools/src/common/file_utils.dart' ;
1112import 'package:flutter_plugin_tools/src/format_command.dart' ;
1213import 'package:path/path.dart' as p;
1314import 'package:test/test.dart' ;
@@ -106,6 +107,42 @@ void main() {
106107 ]));
107108 });
108109
110+ test ('does not format .dart files with pragma' , () async {
111+ const List <String > formattedFiles = < String > [
112+ 'lib/a.dart' ,
113+ 'lib/src/b.dart' ,
114+ 'lib/src/c.dart' ,
115+ ];
116+ const String unformattedFile = 'lib/src/d.dart' ;
117+ final Directory pluginDir = createFakePlugin (
118+ 'a_plugin' ,
119+ packagesDir,
120+ extraFiles: < String > [
121+ ...formattedFiles,
122+ unformattedFile,
123+ ],
124+ );
125+
126+ final p.Context posixContext = p.posix;
127+ childFileWithSubcomponents (pluginDir, posixContext.split (unformattedFile))
128+ .writeAsStringSync (
129+ '// copyright bla bla\n // This file is hand-formatted.\n code...' );
130+
131+ await runCapturingPrint (runner, < String > ['format' ]);
132+
133+ expect (
134+ processRunner.recordedCalls,
135+ orderedEquals (< ProcessCall > [
136+ ProcessCall (
137+ getFlutterCommand (mockPlatform),
138+ < String > [
139+ 'format' ,
140+ ..._getPackagesDirRelativePaths (pluginDir, formattedFiles)
141+ ],
142+ packagesDir.path),
143+ ]));
144+ });
145+
109146 test ('fails if flutter format fails' , () async {
110147 const List <String > files = < String > [
111148 'lib/a.dart' ,
0 commit comments