Skip to content

Commit

Permalink
Handle Windows paths cleanly (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Lesches authored Jan 24, 2025
1 parent ae2275f commit aa54e55
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gen_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ Future<void> installDartPlugin() async {
}
}

extension on FileSystemEntity {
String get filename => path.replaceAll(r"\", "/").split("/").last;
}

Future<void> generateProtobuf(String inputDir, String output) async {
const command = "protoc";
final files = await Directory(inputDir).list().toList();
// For some reason, Linux does not like `./*.proto`, so we must list all files
final filenames = [
for (final file in files)
if (file.path.endsWith(".proto"))
"$inputDir/${file.path.split("/").last}",
"$inputDir/${file.filename}",
];
final args = ["--dart_out=$output", "-I", inputDir, ...filenames, "google/protobuf/timestamp.proto"];
final result = await Process.run(command, args);
Expand Down

0 comments on commit aa54e55

Please sign in to comment.