Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
use sync* in _traverse
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Oct 16, 2015
1 parent d3ec8a3 commit 1d1fb0c
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ test() => new TestRunner().testAsync(files: 'test/validate_templates.dart');
void _concatenateFiles(Directory src, File target) {
log('Creating ${target.path}');

List<String> results = [];

_traverse(src, '', results);

String str = results.map((s) => ' ${_toStr(s)}').join(',\n');
String str = _traverse(src, '').map((s) => ' ${_toStr(s)}').join(',\n');

target.writeAsStringSync("""
// Copyright (c) 2014, Google Inc. Please see the AUTHORS file for details.
Expand All @@ -85,27 +81,22 @@ String _toStr(String s) {
}
}

void _traverse(Directory dir, String root, List<String> results) {
Iterable<String> _traverse(Directory dir, String root) sync* {
var files = _listSync(dir, recursive: false, followLinks: false);
for (FileSystemEntity entity in files) {
String name = path.basename(entity.path);

if (entity is Link) continue;

String name = path.basename(entity.path);
if (name == 'pubspec.lock') continue;
if (name.startsWith('.') && name != '.gitignore') continue;

if (entity is Directory) {
_traverse(entity, '${root}${name}/', results);
yield* _traverse(entity, '${root}${name}/');
} else {
File file = entity;
String fileType = _isBinaryFile(name) ? 'binary' : 'text';
String data = CryptoUtils.bytesToBase64(file.readAsBytesSync(),
yield '${root}${name}';
yield _isBinaryFile(name) ? 'binary' : 'text';
yield BASE64.encode((entity as File).readAsBytesSync(),
addLineSeparator: true);

results.add('${root}${name}');
results.add(fileType);
results.add(data);
}
}
}
Expand Down

0 comments on commit 1d1fb0c

Please sign in to comment.