Created
August 11, 2020 17:28
-
-
Save jairoFernandez/11a15dadcbc11485b744441463347e4a to your computer and use it in GitHub Desktop.
Read pubspec.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
import 'package:path/path.dart'; | |
import 'package:yaml/yaml.dart'; | |
Map<String, String> getVersion() { | |
final pathToYaml = | |
join(dirname(Platform.script.toFilePath()), '../../pubspec.yaml'); | |
final f = File(pathToYaml); | |
final yamlText = f.readAsStringSync(); | |
Map yaml = loadYaml(yamlText); | |
return { | |
'name': yaml['name'], | |
'version': yaml['version'], | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment