getPubspecKey function
String
getPubspecKey(
- String key, {
- FileSystem? fs,
- Directory? workingDir,
})
Implementation
String getPubspecKey(String key, {FileSystem? fs, Directory? workingDir}) {
final _fs = fs ?? const LocalFileSystem();
final wd = getCurrentDir(workingDir, fs: _fs).path;
final pubspecFile = _fs.file(path.join(wd, 'pubspec.yaml'));
logger.debug('Getting $key from ${pubspecFile.path}');
final value = pubspecFile
.readAsStringSync()
.split('\n')
.firstWhere((x) => x.startsWith('$key:'))
.split(':')
.last
.trim();
return value;
}