Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
2ef2cc89
Unverified
Commit
2ef2cc89
authored
Nov 30, 2022
by
Christopher Fujino
Committed by
GitHub
Nov 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] add deprecation message for "flutter format" (#116145)
parent
a29796e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
11 deletions
+44
-11
format.dart
packages/flutter_tools/lib/src/commands/format.dart
+11
-0
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+9
-6
format_test.dart
...tter_tools/test/commands.shard/permeable/format_test.dart
+24
-5
No files found.
packages/flutter_tools/lib/src/commands/format.dart
View file @
2ef2cc89
...
...
@@ -32,6 +32,17 @@ class FormatCommand extends FlutterCommand {
@override
String
get
invocation
=>
'
${runner?.executableName}
$name
<one or more paths>'
;
@override
final
bool
deprecated
=
true
;
@override
String
get
deprecationWarning
{
return
'
${globals.logger.terminal.warningMark}
The "format" command is '
'deprecated and will be removed in a future version of Flutter. '
'Please use the "dart format" sub-command instead, which takes all '
'of the same command-line arguments as "flutter format".
\n
'
;
}
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
final
String
dartBinary
=
globals
.
artifacts
!.
getHostArtifact
(
HostArtifact
.
engineDartBinary
).
path
;
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
2ef2cc89
...
...
@@ -1269,14 +1269,17 @@ abstract class FlutterCommand extends Command<void> {
);
}
@visibleForOverriding
String
get
deprecationWarning
{
return
'
${globals.logger.terminal.warningMark}
The "
$name
" command is '
'deprecated and will be removed in a future version of Flutter. '
'See https://flutter.dev/docs/development/tools/sdk/releases '
'for previous releases of Flutter.
\n
'
;
}
void
_printDeprecationWarning
()
{
if
(
deprecated
)
{
globals
.
printWarning
(
'
${globals.logger.terminal.warningMark}
The "
$name
" command is deprecated and '
'will be removed in a future version of Flutter. '
'See https://flutter.dev/docs/development/tools/sdk/releases '
'for previous releases of Flutter.
\n
'
,
);
globals
.
printWarning
(
deprecationWarning
);
}
}
...
...
packages/flutter_tools/test/commands.shard/permeable/format_test.dart
View file @
2ef2cc89
...
...
@@ -4,31 +4,48 @@
import
'package:args/command_runner.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/
io
.dart'
;
import
'package:flutter_tools/src/base/
logger
.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/format.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fakes.dart'
;
import
'../../src/test_flutter_command_runner.dart'
;
void
main
(
)
{
group
(
'format'
,
()
{
late
Directory
tempDir
;
late
FakeStdio
mockStdio
;
late
BufferLogger
logger
;
setUp
(()
{
Cache
.
disableLocking
();
tempDir
=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools_format_test.'
);
mockStdio
=
FakeStdio
();
logger
=
BufferLogger
.
test
();
});
tearDown
(()
{
tryToDelete
(
tempDir
);
});
testUsingContext
(
'shows deprecation warning'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
);
final
File
srcFile
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
projectPath
,
'lib'
,
'main.dart'
));
final
String
original
=
srcFile
.
readAsStringSync
();
srcFile
.
writeAsStringSync
(
original
);
final
FormatCommand
command
=
FormatCommand
(
verboseHelp:
false
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'format'
,
srcFile
.
path
]);
expect
(
logger
.
warningText
,
contains
(
'The "format" command is deprecated and will be removed in a future version of Flutter'
),
);
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
logger
,
});
testUsingContext
(
'a file'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
);
...
...
@@ -43,7 +60,7 @@ void main() {
final
String
formatted
=
srcFile
.
readAsStringSync
();
expect
(
formatted
,
original
);
},
overrides:
<
Type
,
Generator
>{
Stdio:
()
=>
mockStdio
,
Logger:
()
=>
logger
,
});
testUsingContext
(
'dry-run'
,
()
async
{
...
...
@@ -61,6 +78,8 @@ void main() {
final
String
shouldNotFormatted
=
srcFile
.
readAsStringSync
();
expect
(
shouldNotFormatted
,
nonFormatted
);
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
logger
,
});
testUsingContext
(
'dry-run with -n'
,
()
async
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment