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
fa5f3da6
Unverified
Commit
fa5f3da6
authored
Jan 25, 2019
by
Jonah Williams
Committed by
GitHub
Jan 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update flutter clean to remove .dart_tool directory (#27054)
parent
02dbb08c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
10 deletions
+71
-10
clean.dart
packages/flutter_tools/lib/src/commands/clean.dart
+20
-10
clean_test.dart
packages/flutter_tools/test/commands/clean_test.dart
+51
-0
No files found.
packages/flutter_tools/lib/src/commands/clean.dart
View file @
fa5f3da6
...
...
@@ -8,6 +8,7 @@ import '../base/common.dart';
import
'../base/file_system.dart'
;
import
'../build_info.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../runner/flutter_command.dart'
;
class
CleanCommand
extends
FlutterCommand
{
...
...
@@ -19,22 +20,31 @@ class CleanCommand extends FlutterCommand {
final
String
name
=
'clean'
;
@override
final
String
description
=
'Delete the build/
directory
.'
;
final
String
description
=
'Delete the build/
and .dart_tool/ directories
.'
;
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
final
Directory
buildDir
=
fs
.
directory
(
getBuildDirectory
());
printStatus
(
"Deleting '
${buildDir.path}${fs.path.separator}
'."
);
if
(!
buildDir
.
existsSync
())
return
null
;
printStatus
(
"Deleting '
${buildDir.path}${fs.path.separator}
'."
);
if
(
buildDir
.
existsSync
())
{
try
{
buildDir
.
deleteSync
(
recursive:
true
);
}
catch
(
error
)
{
throwToolExit
(
error
.
toString
());
}
}
return
null
;
printStatus
(
"Deleting '
${flutterProject.dartTool.path}${fs.path.separator}
'."
);
if
(
flutterProject
.
dartTool
.
existsSync
())
{
try
{
flutterProject
.
dartTool
.
deleteSync
(
recursive:
true
);
}
catch
(
error
)
{
throwToolExit
(
error
.
toString
());
}
}
return
const
FlutterCommandResult
(
ExitStatus
.
success
);
}
}
packages/flutter_tools/test/commands/clean_test.dart
0 → 100644
View file @
fa5f3da6
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/config.dart'
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/commands/clean.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
void
main
(
)
{
final
MockFileSystem
mockFileSystem
=
MockFileSystem
();
final
MockDirectory
currentDirectory
=
MockDirectory
();
final
MockDirectory
exampleDirectory
=
MockDirectory
();
final
MockDirectory
buildDirectory
=
MockDirectory
();
final
MockDirectory
dartToolDirectory
=
MockDirectory
();
final
MockFile
pubspec
=
MockFile
();
final
MockFile
examplePubspec
=
MockFile
();
when
(
mockFileSystem
.
currentDirectory
).
thenReturn
(
currentDirectory
);
when
(
currentDirectory
.
childDirectory
(
'example'
)).
thenReturn
(
exampleDirectory
);
when
(
currentDirectory
.
childFile
(
'pubspec.yaml'
)).
thenReturn
(
pubspec
);
when
(
pubspec
.
path
).
thenReturn
(
'/test/pubspec.yaml'
);
when
(
exampleDirectory
.
childFile
(
'pubspec.yaml'
)).
thenReturn
(
examplePubspec
);
when
(
currentDirectory
.
childDirectory
(
'.dart_tool'
)).
thenReturn
(
dartToolDirectory
);
when
(
examplePubspec
.
path
).
thenReturn
(
'/test/example/pubspec.yaml'
);
when
(
mockFileSystem
.
isFileSync
(
'/test/pubspec.yaml'
)).
thenReturn
(
false
);
when
(
mockFileSystem
.
isFileSync
(
'/test/example/pubspec.yaml'
)).
thenReturn
(
false
);
when
(
mockFileSystem
.
directory
(
'build'
)).
thenReturn
(
buildDirectory
);
when
(
mockFileSystem
.
path
).
thenReturn
(
fs
.
path
);
when
(
buildDirectory
.
existsSync
()).
thenReturn
(
true
);
when
(
dartToolDirectory
.
existsSync
()).
thenReturn
(
true
);
group
(
CleanCommand
,
()
{
testUsingContext
(
'removes build and .dart_tool directories'
,
()
async
{
await
CleanCommand
().
runCommand
();
verify
(
buildDirectory
.
deleteSync
(
recursive:
true
)).
called
(
1
);
verify
(
dartToolDirectory
.
deleteSync
(
recursive:
true
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
mockFileSystem
,
Config:
()
=>
null
,
});
});
}
class
MockFileSystem
extends
Mock
implements
FileSystem
{}
class
MockFile
extends
Mock
implements
File
{}
class
MockDirectory
extends
Mock
implements
Directory
{}
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