copyTemplatesToScriptPath method

Future<void> copyTemplatesToScriptPath(
  1. String defaultTemplateDirPath
)

Copy templates to default directory

Implementation

Future<void> copyTemplatesToScriptPath(String defaultTemplateDirPath) async {
  // TODO(AlexeyBukin): make generator for this list
  const resources = [
    'package:elementary_cli/templates/widget.dart.tp',
    'package:elementary_cli/templates/model.dart.tp',
    'package:elementary_cli/templates/test_wm.dart.tp',
    'package:elementary_cli/templates/widget_model.dart.tp',
  ];

  for (final resource in resources) {
    final resolvedUri = await Isolate.resolvePackageUri(Uri.parse(resource));
    if (resolvedUri != null) {
      final fileWithExtension = p.split(resolvedUri.toString()).last;
      File.fromUri(resolvedUri)
          .copySync(p.join(defaultTemplateDirPath, fileWithExtension));
    }
  }
}