unpackBundle function

void unpackBundle(
  1. MasonBundle bundle,
  2. Directory target
)

Unpack the bundle in the target directory.

Implementation

void unpackBundle(MasonBundle bundle, Directory target) {
  for (final file in bundle.files) {
    _unbundleFile(file, path.join(target.path, BrickYaml.dir));
  }
  for (final hook in bundle.hooks) {
    _unbundleFile(hook, path.join(target.path, BrickYaml.hooks));
  }
  final brickYaml = BrickYaml(
    name: bundle.name,
    description: bundle.description,
    version: bundle.version,
    environment: bundle.environment,
    vars: bundle.vars,
    repository: bundle.repository,
    publishTo: bundle.publishTo,
  );
  File(path.join(target.path, BrickYaml.file)).writeAsStringSync(
    Yaml.encode(brickYaml.toJson()),
  );

  final readme = bundle.readme;
  if (readme != null) _unbundleFile(readme, target.path);

  final changelog = bundle.changelog;
  if (changelog != null) _unbundleFile(changelog, target.path);

  final license = bundle.license;
  if (license != null) _unbundleFile(license, target.path);
}