[pigeon] Recursively create output target files (#4458)

Recursively creates output target files before trying to write to it.

closes #[128820](https://github.com/flutter/flutter/issues/128820)
This commit is contained in:
Nitin-Poojary
2023-08-08 06:08:39 +05:30
committed by GitHub
parent 31b1849fb3
commit 7bfcc0e80f
5 changed files with 14 additions and 2 deletions

View File

@ -1,3 +1,7 @@
## 10.1.6
* Fixes generation failures when an output file is in a directory that doesn't already exist.
## 10.1.5
* Fixes import in generated Dart test output when overriding package name.

View File

@ -13,7 +13,7 @@ import 'ast.dart';
/// The current version of pigeon.
///
/// This must match the version in pubspec.yaml.
const String pigeonVersion = '10.1.5';
const String pigeonVersion = '10.1.6';
/// Read all the content from [stdin] to a String.
String readStdin() {

View File

@ -389,6 +389,7 @@ IOSink? _openSink(String? output, {String basePath = ''}) {
sink = stdout;
} else {
file = File(path.posix.join(basePath, output));
file.createSync(recursive: true);
sink = file.openWrite();
}
return sink;

View File

@ -2,7 +2,7 @@ name: pigeon
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
version: 10.1.5 # This must match the version in lib/generator_tools.dart
version: 10.1.6 # This must match the version in lib/generator_tools.dart
environment:
sdk: ">=2.19.0 <4.0.0"

View File

@ -366,6 +366,13 @@ Future<int> _runCommandLineTests() async {
'--ast_out',
tempOutput
],
// Test writing a file in a directory that doesn't exist.
<String>[
'--input',
'pigeons/message.dart',
'--dart_out',
'$tempDir/subdirectory/does/not/exist/message.g.dart',
],
];
int exitCode = 0;