print the dartlang atom plugin version from flutter doctor (#4242)
This commit is contained in:
parent
be7e00a83f
commit
c98ce02417
@ -245,40 +245,46 @@ class AtomValidator extends DoctorValidator {
|
|||||||
|
|
||||||
bool atomDirExists = FileSystemEntity.isDirectorySync(_getAtomHomePath());
|
bool atomDirExists = FileSystemEntity.isDirectorySync(_getAtomHomePath());
|
||||||
if (!atomDirExists) {
|
if (!atomDirExists) {
|
||||||
messages.add(new ValidationMessage.error(
|
messages.add(new ValidationMessage.error('Atom not installed; download at https://atom.io.'));
|
||||||
'Atom not installed; download at https://atom.io.'
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
installCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasPackage('flutter')) {
|
|
||||||
messages.add(new ValidationMessage.error(
|
|
||||||
'Flutter plugin not installed; this adds Flutter specific functionality to Atom.\n'
|
|
||||||
'Install the \'flutter\' plugin in Atom or run \'apm install flutter\'.'
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
installCount++;
|
installCount++;
|
||||||
|
|
||||||
try {
|
if (!_validateHasPackage(messages, 'flutter', 'Flutter'))
|
||||||
String flutterPluginPath = path.join(_getAtomHomePath(), 'packages', 'flutter');
|
installCount++;
|
||||||
File packageFile = new File(path.join(flutterPluginPath, 'package.json'));
|
|
||||||
dynamic packageInfo = JSON.decode(packageFile.readAsStringSync());
|
if (!_validateHasPackage(messages, 'dartlang', 'Dart'))
|
||||||
String version = packageInfo['version'];
|
installCount++;
|
||||||
messages.add(new ValidationMessage('Atom installed; Flutter plugin version $version'));
|
|
||||||
} catch (error) {
|
|
||||||
printTrace('Unable to read flutter plugin version: $error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ValidationResult(
|
return new ValidationResult(
|
||||||
installCount == 2
|
installCount == 3
|
||||||
? ValidationType.installed
|
? ValidationType.installed
|
||||||
: installCount == 1 ? ValidationType.partial : ValidationType.missing,
|
: installCount == 1 ? ValidationType.partial : ValidationType.missing,
|
||||||
messages
|
messages
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _validateHasPackage(List<ValidationMessage> messages, String packageName, String description) {
|
||||||
|
if (!hasPackage(packageName)) {
|
||||||
|
messages.add(new ValidationMessage(
|
||||||
|
'$packageName plugin not installed; this adds $description specific functionality to Atom.\n'
|
||||||
|
'Install the plugin from Atom or run \'apm install $packageName\'.'
|
||||||
|
));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
String flutterPluginPath = path.join(_getAtomHomePath(), 'packages', packageName);
|
||||||
|
File packageFile = new File(path.join(flutterPluginPath, 'package.json'));
|
||||||
|
Map<String, dynamic> packageInfo = JSON.decode(packageFile.readAsStringSync());
|
||||||
|
String version = packageInfo['version'];
|
||||||
|
messages.add(new ValidationMessage('$packageName plugin version $version'));
|
||||||
|
} catch (error) {
|
||||||
|
printTrace('Unable to read $packageName plugin version: $error');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool hasPackage(String packageName) {
|
bool hasPackage(String packageName) {
|
||||||
String packagePath = path.join(_getAtomHomePath(), 'packages', packageName);
|
String packagePath = path.join(_getAtomHomePath(), 'packages', packageName);
|
||||||
return FileSystemEntity.isDirectorySync(packagePath);
|
return FileSystemEntity.isDirectorySync(packagePath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user