resolveWorkspaceRoot function

String resolveWorkspaceRoot(
  1. String from
)

The workspace: the nearest ancestor of from holding a .tom_metadata directory, which is what makes it the workspace.

Implementation

String resolveWorkspaceRoot(String from) {
  var dir = p.normalize(p.absolute(from));
  while (!Directory(p.join(dir, '.tom_metadata')).existsSync()) {
    final parent = p.dirname(dir);
    if (parent == dir) {
      throw StateError('no .tom_metadata above $from');
    }
    dir = parent;
  }
  return dir;
}