getOwnPath static method
get path of git_hooks library
Implementation
static String? getOwnPath() {
var pacPath = path.fromUri(path.current + '/.packages');
var pac = File(pacPath);
var a = pac.readAsStringSync();
var b = a.split('\n');
String? resPath;
b.forEach((v) {
if (v.startsWith('git_hooks:')) {
var index = v.indexOf(':');
var lastIndex = v.lastIndexOf('lib');
resPath = v.substring(index + 1, lastIndex);
}
});
resPath = path.fromUri(resPath);
if (path.isRelative(resPath!)) {
resPath = path.canonicalize(resPath!);
}
if (!Directory(resPath!).existsSync()) {
return null;
}
return resPath;
}