Skip to content

Commit fc52cb2

Browse files
committed
πŸ› Fix the default build file definition
1 parent b605805 commit fc52cb2

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

β€Žpackages/command/bin/flutter_gen_command.dartβ€Ž

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ void main(List<String> args) {
1818
'build',
1919
abbr: 'b',
2020
help: 'Set the path of build.yaml.',
21-
defaultsTo: 'build.yaml',
2221
);
2322

2423
parser.addFlag(
@@ -57,11 +56,11 @@ void main(List<String> args) {
5756
}
5857
final pubspecFile = File(pubspecPath).absolute;
5958

60-
final buildPath = safeCast<String>(results['build']);
61-
if (buildPath == null || buildPath.trim().isEmpty) {
59+
final buildPath = safeCast<String>(results['build'])?.trim();
60+
if (buildPath?.isEmpty ?? false) {
6261
throw ArgumentError('Invalid value $buildPath', 'build');
6362
}
64-
final buildFile = File(buildPath).absolute;
63+
final buildFile = buildPath == null ? null : File(buildPath).absolute;
6564

6665
FlutterGenerator(pubspecFile, buildFile: buildFile).build();
6766
}

β€Žpackages/core/lib/settings/config.dartβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ Config loadPubspecConfig(File pubspecFile, {File? buildFile}) {
3232
'[FlutterGen] Reading options from $pubspecLocaleHint',
3333
);
3434

35+
// Fallback to the build.yaml when no build file has been specified and
36+
// the default one exists.
37+
if (buildFile == null && File('build.yaml').existsSync()) {
38+
buildFile = File('build.yaml');
39+
}
40+
3541
if (buildFile != null) {
3642
if (buildFile.existsSync()) {
3743
final buildContent = buildFile.readAsStringSync();

0 commit comments

Comments
Β (0)