inserter 0.0.3 copy "inserter: ^0.0.3" to clipboard
inserter: ^0.0.3 copied to clipboard

Tooling for inserting String into Files given their respective strategies.

Inserter #

Tooling for inserting String into Files given their respective strategies.

Install #

dart pub add inserter

Usage #

Future<void> main() async {
  final replaceWithAwesome = MatcherBuilder(
    // Use this to determine which line to trigger the line builder.
    matcher: (file, line) => line.contains('// REPLACE WITH AWESOME'),
    
    // The line to be written.
    builder: (file, line) => 'bool isAwesome() => true;',

    // Where the line will go
    strategy: BuilderStrategy.replace, // also below & above
  );
  await Inserter.run(
    files: [File('update_me.dart')],
    builders: [replaceWithAwesome] 
  );
}

What changed in update_me.dart?

void main() {
  print(isAwesome());
}
- // REPLACE WITH AWESOME
+ bool isAwesome() => true;

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);
    }
  });
}
0
likes
0
pub points
9%
popularity

Publisher

verified publisherelijahluckey.com

Tooling for inserting String into Files given their respective strategies.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on inserter