Commit c54d54b7 authored by Devon Carew's avatar Devon Carew

improve the atom validation

parent 0a0f3e7a
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
import 'dart:io'; import 'dart:io';
import 'package:path/path.dart' as path;
import 'android/android_workflow.dart'; import 'android/android_workflow.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/process.dart'; import 'base/os.dart';
import 'globals.dart'; import 'globals.dart';
import 'ios/ios_workflow.dart'; import 'ios/ios_workflow.dart';
...@@ -217,6 +219,15 @@ class ValidationResult { ...@@ -217,6 +219,15 @@ class ValidationResult {
} }
class _AtomValidator extends DoctorValidator { class _AtomValidator extends DoctorValidator {
static String getAtomHomePath() {
final Map<String, String> env = Platform.environment;
if (env['ATOM_HOME'] != null)
return env['ATOM_HOME'];
return os.isWindows
? path.join(env['USERPROFILE'], '.atom')
: path.join(env['HOME'], '.atom');
}
String get label => 'Atom development environment'; String get label => 'Atom development environment';
ValidationResult validate() { ValidationResult validate() {
...@@ -226,24 +237,14 @@ class _AtomValidator extends DoctorValidator { ...@@ -226,24 +237,14 @@ class _AtomValidator extends DoctorValidator {
); );
ValidationType atomExists() { ValidationType atomExists() {
return exitsHappy(<String>['atom', '--version']) ? ValidationType.installed : ValidationType.missing; bool atomDirExists = FileSystemEntity.isDirectorySync(getAtomHomePath());
return atomDirExists ? ValidationType.installed : ValidationType.missing;
}; };
ValidationType flutterPluginExists() { ValidationType flutterPluginExists() {
try { String flutterPluginPath = path.join(getAtomHomePath(), 'packages', 'flutter');
// apm list -b -p -i bool flutterPluginExists = FileSystemEntity.isDirectorySync(flutterPluginPath);
List<String> args = <String>['list', '-b', '-p', '-i']; return flutterPluginExists ? ValidationType.installed : ValidationType.missing;
printTrace('apm ${args.join(' ')}');
ProcessResult result = Process.runSync('apm', args);
if (result.exitCode != 0)
return ValidationType.missing;
bool available = (result.stdout as String).split('\n').any((String line) {
return line.startsWith('flutter@');
});
return available ? ValidationType.installed : ValidationType.missing;
} catch (error) {
return ValidationType.missing;
}
}; };
atomValidator.addValidator(new Validator( atomValidator.addValidator(new Validator(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment