diff --git a/dev/tools/java_and_objc_doc.dart b/dev/tools/java_and_objc_doc.dart index 2cdaefba34..af8b745baa 100644 --- a/dev/tools/java_and_objc_doc.dart +++ b/dev/tools/java_and_objc_doc.dart @@ -7,6 +7,7 @@ import 'dart:math'; import 'package:archive/archive.dart'; import 'package:http/http.dart' as http; +import 'package:path/path.dart' as path; const String kDocRoot = 'dev/docs/doc'; @@ -63,6 +64,12 @@ Future generateDocs(String url, String docName, String checkFile) async { } } + /// If object then copy files to old location if the archive is using the new location. + final bool exists = Directory('$kDocRoot/$docName/objectc_docs').existsSync(); + if (exists) { + copyFolder(Directory('$kDocRoot/$docName/objectc_docs'), Directory('$kDocRoot/$docName/')); + } + final File testFile = File('${output.path}/$checkFile'); if (!testFile.existsSync()) { print('Expected file ${testFile.path} not found'); @@ -70,3 +77,17 @@ Future generateDocs(String url, String docName, String checkFile) async { } print('$docName ready to go!'); } + +/// Copies the files in a directory recursively to a new location. +void copyFolder(Directory source, Directory destination) { + source.listSync() + .forEach((FileSystemEntity entity) { + if (entity is Directory) { + final Directory newDirectory = Directory(path.join(destination.absolute.path, path.basename(entity.path))); + newDirectory.createSync(); + copyFolder(entity.absolute, newDirectory); + } else if (entity is File) { + entity.copySync(path.join(destination.path, path.basename(entity.path))); + } + }); +}