Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Split git and path utilities into packages - #179

Closed
ecraig12345 wants to merge 1 commit into
masterfrom
ecraig/split-git
Closed

Split git and path utilities into packages#179
ecraig12345 wants to merge 1 commit into
masterfrom
ecraig/split-git

Conversation

@ecraig12345

@ecraig12345 ecraig12345 commented Sep 15, 2022

Copy link
Copy Markdown
Member

Start splitting utilities into packages:

  • workspace-tools-git contains git helpers
  • workspace-tools-paths contains very basic path helpers

For now, findProjectRoot is staying in workspace-tools since it uses the more complex workspace implementation helpers. Later I'll factor out the core path logic (without extra deps) so it can be moved into the paths package.

I also moved the fixtures from packages/workspace-tools/src/__fixtures__ to scripts/jest/__fixtures__, along with the fixture setup helper. This is so that multiple packages can use the fixtures. moved to #185

const gitRoot = findGitRoot(cwd);

let packageJson: Partial<PackageInfo> = {};
let packageJson: { repository?: string | { url?: string } } = {};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the PackageInfo type since that's now defined in a different package (which consumes this one)

* Throws if `cwd` is not in a Git repository.
*/
export function findGitRoot(cwd: string) {
const result = spawnSync("git", ["rev-parse", "--show-toplevel"], { cwd });

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now uses spawnSync directly since the git() utility is defined in another package (which consumes this one). I didn't bother with changing the maxBuffer here since the output should be very short.

return workspaceRoot || findGitRoot(cwd);
}

/** @deprecated */

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was included in the initial repo creation but seems to be unused in workspace-tools, beachball, backfill, and lage

@ecraig12345
ecraig12345 force-pushed the ecraig/split-git branch 2 times, most recently from 54dd56b to 6dd9059 Compare September 17, 2022 01:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant