exec method

  1. @override
Future<void> exec(
  1. ExecContext context
)
override

Run command.

The contents of katana.yaml and the arguments of the command are passed to context.

コマンドを実行します。

contextkatana.yamlの内容やコマンドの引数が渡されます。

Implementation

@override
Future<void> exec(ExecContext context) async {
  final bin = context.yaml.getAsMap("bin");
  final lefthook = bin.get("lefthook", "lefthook");
  await addFlutterImport(
    [
      "import_sorter",
    ],
    development: true,
  );
  label("Create lefthook.yaml");
  final gitDir = await findGitDirectory(Directory.current);
  final relativePath = Directory.current.difference(gitDir);
  await const LefthookCliCode().generateFile(
    "${relativePath.isEmpty ? "" : "$relativePath/"}lefthook.yaml",
  );
  await command(
    "Install lefthook.",
    [
      lefthook,
      "install",
    ],
    workingDirectory: gitDir?.path,
  );
}