Skip to content

Commit

Permalink
fix(simple-git): updated to the modern syntax for defining the repo root
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Feb 4, 2024
1 parent 3f89ad9 commit 088fa7a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/vcs/git/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function getExistingRemotes(git) {
}

async function defineRemoteOrigin(projectRoot, origin) {
const git = simpleGit(projectRoot);
const git = simpleGit({baseDir: projectRoot});
const existingRemotes = await getExistingRemotes(git);

if (existingRemotes.includes('origin')) {
Expand Down Expand Up @@ -68,7 +68,7 @@ export async function initialize(
decisions
) {
if (gitRepoShouldBeInitialized) {
const git = simpleGit(projectRoot);
const git = simpleGit({baseDir: projectRoot});
if (await git.checkIsRepo('root')) {
info('Git repository already exists');

Expand Down
2 changes: 1 addition & 1 deletion src/vcs/git/git.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('git', () => {
addRemote = vi.fn();

when(simpleGit.simpleGit)
.calledWith(projectRoot)
.calledWith({baseDir: projectRoot})
.mockReturnValue({checkIsRepo, init, remote, listRemote, addRemote});
});

Expand Down
4 changes: 2 additions & 2 deletions test/integration/features/step_definitions/vcs/git-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Given(/^the project should be versioned in git$/, async function () {
this.setAnswerFor(questionNames.GIT_REPO, true);
this.setAnswerFor(questionNames.REPO_HOST, 'Other');

td.when(this.git.simpleGit(process.cwd())).thenReturn(simpleGitInstance);
td.when(this.git.simpleGit({baseDir: process.cwd()})).thenReturn(simpleGitInstance);
td.when(simpleGitInstance.checkIsRepo('root')).thenResolve(false);
td.when(simpleGitInstance.listRemote())
.thenReject(new GitError(null, 'fatal: No remote configured to list refs from.\n'));
Expand All @@ -39,7 +39,7 @@ Given('the project root is already initialized as a git repository', async funct
this.setAnswerFor(questionNames.GIT_REPO, true);
this.setAnswerFor(questionNames.REPO_HOST, undefined);

td.when(this.git.simpleGit(process.cwd())).thenReturn(simpleGitInstance);
td.when(this.git.simpleGit({baseDir: process.cwd()})).thenReturn(simpleGitInstance);
td.when(simpleGitInstance.checkIsRepo('root')).thenResolve(true);
td.when(simpleGitInstance.listRemote()).thenResolve(['origin']);
td.when(simpleGitInstance.remote(['get-url', 'origin']))
Expand Down

0 comments on commit 088fa7a

Please sign in to comment.