@@ -324,7 +324,7 @@ Future<void> runDoc(ArgResults commandResults) async {
324324 'help' => _docHelp (),
325325 'package' => _docPackage (commandResults, withStats: stats),
326326 'sdk' => docSdk (withStats: stats),
327- 'testing-package' => docTestingPackage (),
327+ 'testing-package' => docTestingPackage (withStats : stats ),
328328 _ => throw UnimplementedError ('Unknown doc target: "$target "' ),
329329 };
330330}
@@ -515,11 +515,15 @@ Map<String, String> createThrowawayPubCache() {
515515final String _defaultPubCache = Platform .environment['PUB_CACHE' ] ??
516516 path.context.resolveTildePath ('~/.pub-cache' );
517517
518- Future <String > docTestingPackage () async {
518+ Future <String > docTestingPackage ({
519+ bool withStats = false ,
520+ }) async {
519521 var testPackagePath = testPackage.absolute.path;
520522 var launcher = SubprocessLauncher ('doc-test-package' );
521- await launcher.runStreamedDartCommand (['pub' , 'get' ],
522- workingDirectory: testPackagePath);
523+ await launcher.runStreamedDartCommand (
524+ ['pub' , 'get' ],
525+ workingDirectory: testPackagePath,
526+ );
523527 var outputPath = _testingPackageDocsDir.absolute.path;
524528 await launcher.runStreamedDartCommand (
525529 [
@@ -533,7 +537,21 @@ Future<String> docTestingPackage() async {
533537 '--pretty-index-json' ,
534538 ],
535539 workingDirectory: testPackagePath,
540+ withStats: withStats,
536541 );
542+
543+ if (withStats && (Platform .isLinux || Platform .isMacOS)) {
544+ // Prints all files in `outputPath`, newline-separated.
545+ var findResult = Process .runSync ('find' , [outputPath, '-type' , 'f' ]);
546+ var fileCount = (findResult.stdout as String ).split ('\n ' ).length;
547+ var diskUsageResult = Process .runSync ('du' , ['-sh' , outputPath]);
548+ // Output looks like
549+ // 146M /var/folders/72/ltck4q353hsg3bn8kpkg7f84005w15/T/sdkdocsHcquiB
550+ var diskUsageNumber =
551+ (diskUsageResult.stdout as String ).trim ().split (RegExp ('\\ s+' )).first;
552+ print ('Generated $fileCount files amounting to $diskUsageNumber .' );
553+ }
554+
537555 return outputPath;
538556}
539557
0 commit comments