-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbfd0be
commit 0313331
Showing
5 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
example/lib/widgets/utils/bottom/catalog/test/fab_widget.test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'dart:io'; | ||
|
||
import '../../preview_builder/preview_builder.dart'; | ||
import '../../utils/configuration.dart'; | ||
import '../base/base_task.dart'; | ||
|
||
class TestTask extends BaseTask { | ||
@override | ||
Future<void> work(List<String> args) async { | ||
final base = args.isEmpty ? '' : '${args.first}/'; | ||
|
||
var config = loadConfigFile(base); | ||
|
||
final prefixValue = config['prefix'] ?? 'preview'; | ||
|
||
final dir = Directory('./$base${config['base']}'); | ||
await dir.create(recursive: true); | ||
|
||
final dirOutPut = Directory('./$base${config['base']}/${config['output']}'); | ||
await dirOutPut.create(recursive: true); | ||
|
||
final List<FileSystemEntity> entities = | ||
await dir.list(recursive: true).toList(); | ||
|
||
final files = <FileSystemEntity>[]; | ||
|
||
for (FileSystemEntity fileSystemEntity in entities) { | ||
try { | ||
if (fileSystemEntity is Directory) continue; | ||
if (fileSystemEntity.path.endsWith('.DS_Store')) continue; | ||
final File file = File(fileSystemEntity.path); | ||
if (file.path.contains('.$prefixValue.')) continue; | ||
final content = await file.readAsString(); | ||
if (content.contains('@Preview(')) { | ||
files.add(fileSystemEntity); | ||
} | ||
} catch (e) { | ||
print(e); | ||
} | ||
} | ||
|
||
for (FileSystemEntity fileSystemEntity in files) { | ||
final File file = File(fileSystemEntity.path); | ||
var preview = await previewOnFile(base, config, file.path); | ||
var previewAnnotation = await findPreviewAnnotation(file.path); | ||
if (previewAnnotation == null) continue; | ||
var className = await findClassName(file.path); | ||
if (className == null) continue; | ||
if (preview == null) continue; | ||
|
||
await generateTest( | ||
file.path, | ||
className, | ||
prefixValue, | ||
); | ||
} | ||
} | ||
} |