resolveWorkspace = ({
  from = process.cwd(),
  fs = nodeFs,
} = {}) => {
  let current = from
  // eslint-disable-next-line no-constant-condition
  while (true) {
    const nicePath = hrPath(current)
    log.debug(`Searching for workspace in ${nicePath}`)
    if (isReadableFileSync(path.join(current, PACKAGE_JSON), { fs })) {
      log.debug(`Found workspace in ${nicePath}`)
      return current
    }
    const parent = path.join(current, '..')
    if (parent === current) {
      throw new NoWorkspaceError(
        `Could not find a workspace from ${hrPath(from)}`
      )
    }
    current = parent
  }
}
Resolves a workspace directory from the given directory.

A workspace is defined as a directory containing a `package.json`, which we
assume means that a `node_modules/` could be a sibling.

@remarks
This is not recursive due to the potential for stack overflows (though
unlikely).
@param {ResolveWorkspaceOptions} options Options
@returns {string} Path to workspace directory