fromBundle static method

Future<MasonGenerator> fromBundle(
  1. MasonBundle bundle
)

Factory which creates a MasonGenerator based on a local MasonBundle.

Implementation

static Future<MasonGenerator> fromBundle(MasonBundle bundle) async {
  final bytes = await Isolate.run(
    () => utf8.encode(json.encode(bundle.toJson())),
  );
  final hash = sha1.convert(bytes).toString();
  final target = Directory(
    p.join(BricksJson.bundled.path, '${bundle.name}_${bundle.version}_$hash'),
  );
  if (!target.existsSync()) unpackBundle(bundle, target);
  return MasonGenerator._fromBrick(target.path);
}