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
fc015f52
Unverified
Commit
fc015f52
authored
Sep 28, 2022
by
Jesús S Guerrero
Committed by
GitHub
Sep 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use directory exists instead of path.dirname (#112219)
parent
78e94155
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
6 deletions
+61
-6
os.dart
packages/flutter_tools/lib/src/base/os.dart
+5
-5
build_aar.dart
packages/flutter_tools/lib/src/commands/build_aar.dart
+16
-1
pub_get_test.dart
...tter_tools/test/commands.shard/hermetic/pub_get_test.dart
+16
-0
build_aar_test.dart
...r_tools/test/commands.shard/permeable/build_aar_test.dart
+24
-0
No files found.
packages/flutter_tools/lib/src/base/os.dart
View file @
fc015f52
...
...
@@ -590,15 +590,15 @@ class _WindowsUtils extends OperatingSystemUtils {
String
?
findProjectRoot
(
FileSystem
fileSystem
,
[
String
?
directory
])
{
const
String
kProjectRootSentinel
=
'pubspec.yaml'
;
directory
??=
fileSystem
.
currentDirectory
.
path
;
Directory
currentDirectory
=
fileSystem
.
directory
(
directory
).
absolute
;
while
(
true
)
{
if
(
fileSystem
.
isFileSync
(
fileSystem
.
path
.
join
(
directory
!,
kProjectRootSentinel
)
))
{
return
directory
;
if
(
currentDirectory
.
childFile
(
kProjectRootSentinel
).
existsSync
(
))
{
return
currentDirectory
.
path
;
}
final
String
parent
=
fileSystem
.
path
.
dirname
(
directory
);
if
(
directory
==
parent
)
{
if
(!
currentDirectory
.
existsSync
()
||
currentDirectory
.
parent
.
path
==
currentDirectory
.
path
)
{
return
null
;
}
directory
=
parent
;
currentDirectory
=
currentDirectory
.
parent
;
}
}
...
...
packages/flutter_tools/lib/src/commands/build_aar.dart
View file @
fc015f52
...
...
@@ -155,6 +155,21 @@ class BuildAarCommand extends BuildSubCommand {
if
(
remainingArguments
.
isEmpty
)
{
return
FlutterProject
.
current
();
}
return
FlutterProject
.
fromDirectory
(
globals
.
fs
.
directory
(
findProjectRoot
(
globals
.
fs
,
remainingArguments
.
first
)));
final
File
mainFile
=
globals
.
fs
.
file
(
remainingArguments
.
first
);
final
String
path
;
if
(!
mainFile
.
existsSync
())
{
final
Directory
pathProject
=
globals
.
fs
.
directory
(
remainingArguments
.
first
);
if
(!
pathProject
.
existsSync
())
{
throwToolExit
(
'
${remainingArguments.first}
does not exist'
);
}
path
=
pathProject
.
path
;
}
else
{
path
=
mainFile
.
parent
.
path
;
}
final
String
?
projectRoot
=
findProjectRoot
(
globals
.
fs
,
path
);
if
(
projectRoot
==
null
)
{
throwToolExit
(
'
${mainFile.parent.path}
is not a valid flutter project'
);
}
return
FlutterProject
.
fromDirectory
(
globals
.
fs
.
directory
(
projectRoot
));
}
}
packages/flutter_tools/test/commands.shard/hermetic/pub_get_test.dart
View file @
fc015f52
...
...
@@ -114,6 +114,22 @@ void main() {
FileSystem:
()
=>
fileSystem
,
});
testUsingContext
(
'pub get throws error on missing directory'
,
()
async
{
final
PackagesGetCommand
command
=
PackagesGetCommand
(
'get'
,
false
);
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
command
);
try
{
await
commandRunner
.
run
(<
String
>[
'get'
,
'missing_dir'
]);
fail
(
'expected an exception'
);
}
on
Exception
catch
(
e
)
{
expect
(
e
.
toString
(),
contains
(
'Expected to find project root in missing_dir'
));
}
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
pub
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
FileSystem:
()
=>
fileSystem
,
});
testUsingContext
(
'pub get triggers localizations generation when generate: true'
,
()
async
{
final
File
pubspecFile
=
fileSystem
.
currentDirectory
.
childFile
(
'pubspec.yaml'
)
..
createSync
();
...
...
packages/flutter_tools/test/commands.shard/permeable/build_aar_test.dart
View file @
fc015f52
...
...
@@ -230,6 +230,30 @@ void main() {
});
});
group
(
'throws ToolExit'
,
()
{
testUsingContext
(
'main.dart not found'
,
()
async
{
await
expectLater
(()
async
{
await
runBuildAarCommand
(
'missing_project'
,
arguments:
<
String
>[
'--no-pub'
],
);
},
throwsToolExit
(
message:
'main.dart does not exist'
,
));
});
testUsingContext
(
'flutter project not valid'
,
()
async
{
await
expectLater
(()
async
{
await
runCommandIn
(
tempDir
.
path
,
arguments:
<
String
>[
'--no-pub'
],
);
},
throwsToolExit
(
message:
'is not a valid flutter project'
,
));
});
});
testUsingContext
(
'support ExtraDartFlagOptions'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=module'
]);
...
...
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