createHeader function

String createHeader()

hooks header

Implementation

String createHeader() {
  var rootDir = Directory.current;
  var f = File(rootDir.path + '/pubspec.yaml');
  var text = f.readAsStringSync();
  Map yaml = loadYaml(text);
  String name = yaml['name'] ?? '';
  String author = yaml['author'] ?? '';
  String version = yaml['version'] ?? '';
  String homepage = yaml['homepage'] ?? '';
  return '''
#!/bin/sh
# !!!don"t edit this file
# ${name}
# Hook created by ${author}
#   Version: ${version}
#   At: ${DateTime.now()}
#   See: ${homepage}#readme

# From
#   Homepage: ${homepage}#readme

''';
}