inserter

Last updated:

0 purchases

inserter Image
inserter Images
Add to Cart

Description:

inserter

Inserter #
Tooling for inserting String into Files given their respective strategies.
Install #
dart pub add inserter
copied to clipboard
Usage #
Future<void> main() async {
final replaceWithAwesome = MatcherBuilder(
// Use this to determine which line to trigger the line builder.
matcher: (file, line) async => line.contains('// REPLACE WITH AWESOME'),

// The line to be written.
builder: (file, line) async => 'bool isAwesome() => true;',

// Where the line will go
strategy: BuilderStrategy.replace, // also below & above
);
await Inserter.run(
files: [File('update_me.dart')],
builders: [replaceWithAwesome]
);
}
copied to clipboard
What changed in update_me.dart?
void main() {
print(isAwesome());
}
- // REPLACE WITH AWESOME
+ bool isAwesome() => true;
copied to clipboard
Non UTF-8 encodings #
Extend the InserterBase and provide you own LineConverter method:
class MyOtherInserter extends InserterBase {
MyOtherInserter({
required this.files,
required this.builders,
}) : super({
buffer: StringBuffer(), // typically, allow injecting this for testing.
readLines: (file) {
/// .... not a real method
return Stream.fromFile(file);
}
});
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.