This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 10
10
` --no-push-flags ` . Releases now always tag and push.
11
11
- ** Breaking change** : ` publish ` 's ` --package ` flag has been replaced with the
12
12
` --packages ` flag used by most other packages.
13
+ - Formatting now skips files that contain a line that exactly
14
+ matches the string ` // This file is hand-formatted ` .
13
15
14
16
## 0.5.0
15
17
Original file line number Diff line number Diff line change @@ -206,7 +206,21 @@ class FormatCommand extends PluginCommand {
206
206
207
207
final String fromPath = relativeTo.path;
208
208
209
+ const String handFormattedPragma = '// This file is hand-formatted.' ;
210
+
209
211
return files
212
+ .where ((File file) {
213
+ try {
214
+ return ! file.readAsLinesSync ().contains (handFormattedPragma);
215
+ } catch FileSystemException {
216
+ // If we can't open the file or can't read it as UTF-8, then we just
217
+ // consider it included. It should get filtered out later when we
218
+ // deal with file extensions. (We want the formatters to see the
219
+ // files that we can't read, in case they have opinions about such
220
+ // things as character encodings, etc.)
221
+ return true ;
222
+ }
223
+ })
210
224
.map ((File file) => path.relative (file.path, from: fromPath))
211
225
.where ((String path) =>
212
226
// Ignore files in build/ directories (e.g., headers of frameworks)
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import 'package:args/command_runner.dart';
8
8
import 'package:file/file.dart' ;
9
9
import 'package:file/memory.dart' ;
10
10
import 'package:flutter_plugin_tools/src/common/core.dart' ;
11
+ import 'package:flutter_plugin_tools/src/common/file_utils.dart' ;
11
12
import 'package:flutter_plugin_tools/src/format_command.dart' ;
12
13
import 'package:path/path.dart' as p;
13
14
import 'package:test/test.dart' ;
@@ -85,12 +86,21 @@ void main() {
85
86
'lib/src/b.dart' ,
86
87
'lib/src/c.dart' ,
87
88
];
89
+ const String fileWithOptOut = 'lib/src/d.dart' ;
88
90
final Directory pluginDir = createFakePlugin (
89
91
'a_plugin' ,
90
92
packagesDir,
91
- extraFiles: files,
93
+ extraFiles: < String > [
94
+ ...files,
95
+ fileWithOptOut,
96
+ ],
92
97
);
93
98
99
+ final p.Context posixContext = p.posix;
100
+ childFileWithSubcomponents (pluginDir, posixContext.split (fileWithOptOut))
101
+ .writeAsStringSync (
102
+ '// copyright bla bla\n // This file is hand-formatted.\n code...' );
103
+
94
104
await runCapturingPrint (runner, < String > ['format' ]);
95
105
96
106
expect (
You can’t perform that action at this time.
0 commit comments