pubspec_builder
A builder for extracting the contents of pubspec.yaml into code.
Usage
-
Add this package to your dev_dependencies in
pubspec.yaml
:dependencies: pubspec_parse: ^1.2.0 dev_dependencies: build_runner: ^2.1.11 pubspec_builder: any
-
Run a build:
dart pub run build_runner build
-
lib/gen/pubspec.dart
will be generated with content:// GENERATED CODE - DO NOT MODIFY BY HAND import 'package:pubspec_parse/pubspec_parse.dart'; final pubspec = Pubspec.parse("""...""");
Optional
To change the path of the generated file, create a build.yaml
in the root of your package.
By changing the output
option of this builder, the path can be customized:
targets:
$default:
builders:
pubspec_builder:
options:
output: 'lib/custom/path/to/pubspec.dart'