selectProjectDirectory method
Selects a project directory that is either specified by the global configuration, or files found near the current directory. If no project directory is specified nor found then null is returned.
Does not verify that the directory exists and is a valid Serverpod server directory. See isServerpodServerDirectory for verification.
Implementation
String? selectProjectDirectory() {
// if explicitly set, use the specified directory
final specifiedDir = globalConfiguration.projectDir;
if (specifiedDir != null) {
return specifiedDir.path;
}
// if scloud.<ext> is set or found, use its directory
final configFile = globalConfiguration.projectConfigFile;
if (configFile != null) {
return configFile.parent.path;
}
// if server pubspec.yaml is found near the current directory, use its directory
final serverPubspecFile = _serverPubspecFileFinder();
if (serverPubspecFile != null) {
return p.dirname(serverPubspecFile);
}
return null;
}