Improve error message when missing the package-root

This commit is contained in:
Adam Barth
2015-10-12 14:01:05 -07:00
parent 9c4835100b
commit d9af939995
2 changed files with 17 additions and 2 deletions

View File

@@ -23,8 +23,11 @@ class ArtifactStore {
static String _engineRevision;
static String get engineRevision {
if (_engineRevision == null)
_engineRevision = new File(path.join(packageRoot, 'sky_engine', 'REVISION')).readAsStringSync();
if (_engineRevision == null) {
File revisionFile = new File(path.join(packageRoot, 'sky_engine', 'REVISION'));
if (revisionFile.existsSync())
_engineRevision = revisionFile.readAsStringSync();
}
return _engineRevision;
}

View File

@@ -88,6 +88,18 @@ class FlutterCommandRunner extends CommandRunner {
Logger.root.level = Level.FINE;
ArtifactStore.packageRoot = globalResults['package-root'];
if (!FileSystemEntity.isDirectorySync(ArtifactStore.packageRoot)) {
String message = '${ArtifactStore.packageRoot} is not a valid directory.';
if (ArtifactStore.packageRoot == 'packages') {
if (FileSystemEntity.isFileSync('pubspec.yaml'))
message += '\nDid you run `pub get` in this directory?';
else
message += '\nDid you run this command from the same directory as your pubspec.yaml file?';
}
_logging.severe(message);
return 2;
}
buildConfigurations = _createBuildConfigurations(globalResults);
return super.runCommand(globalResults);