This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1010 ` --no-push-flags ` . Releases now always tag and push.
1111- ** Breaking change** : ` publish ` 's ` --package ` flag has been replaced with the
1212 ` --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 ` .
1315
1416## 0.5.0
1517
Original file line number Diff line number Diff line change @@ -206,7 +206,11 @@ class FormatCommand extends PluginCommand {
206206
207207 final String fromPath = relativeTo.path;
208208
209+ const String handFormattedPragma = '// This file is hand-formatted.' ;
210+
209211 return files
212+ .where ((File file) =>
213+ ! file.readAsLinesSync ().contains (handFormattedPragma))
210214 .map ((File file) => path.relative (file.path, from: fromPath))
211215 .where ((String path) =>
212216 // 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';
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' ;
@@ -85,12 +86,21 @@ void main() {
8586 'lib/src/b.dart' ,
8687 'lib/src/c.dart' ,
8788 ];
89+ const String fileWithOptOut = 'lib/src/d.dart' ;
8890 final Directory pluginDir = createFakePlugin (
8991 'a_plugin' ,
9092 packagesDir,
91- extraFiles: files,
93+ extraFiles: < String > [
94+ ...files,
95+ fileWithOptOut,
96+ ],
9297 );
9398
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+
94104 await runCapturingPrint (runner, < String > ['format' ]);
95105
96106 expect (
You can’t perform that action at this time.
0 commit comments