Skip to content

Commit

Permalink
fix(betterer 🐛): api stability
Browse files Browse the repository at this point in the history
  • Loading branch information
phenomnomnominal committed Nov 30, 2024
1 parent c5f8300 commit e857f86
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/cli/src/init/enable-automerge.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ async function gitconfig(logger: BettererLogger, gitDir: string): Promise<void>

const cliPath = require.resolve('@betterer/cli');
const mergePath = path.resolve(cliPath, '../../bin/betterer.js');
const mergePathRelative = path.relative(gitconfigPath, mergePath);
const mergeCommand = `\tdriver = ${mergePathRelative} merge %A %B`;
const mergeCommand = `\tdriver = ${mergePath} merge %A %B`;

lines.push(MERGE_CONFIG, mergeCommand, '');

Expand Down
6 changes: 3 additions & 3 deletions test/cli/__snapshots__/init-automerge-no-git.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Error: ".git" directory not found in "/". \`--automerge\` only works within a Gi
✅ Create test file: done!
・ created "fixtures/init-automerge/.betterer.ts"!
✅ Update package.json: done!
added "betterer" script to package.json file
added "@betterer/cli" dependency to package.json file
added "typescript" dependency to package.json file
・ "betterer" script already exists, moving on...
・ "@betterer/cli" dependency already exists, moving on...
・ "typescript" dependency already exists, moving on...
🔥 Enable automerge: ".git" directory not found in "/". \`--automerge\` only works within a Git repository.
Error: ".git" directory not found in "/". \`--automerge\` only works within a Git repository.",
Expand Down
2 changes: 1 addition & 1 deletion test/cli/__snapshots__/init-automerge.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`betterer cli > should enable automerge configuration 1`] = `

exports[`betterer cli > should enable automerge configuration 2`] = `
"[merge "betterer"]
driver = ../../../../packages/cli/bin/betterer.js merge %A %B
driver = <root>/packages/cli/bin/betterer.js merge %A %B
"
`;
Expand Down
7 changes: 6 additions & 1 deletion test/cli/init-automerge.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { describe, it, expect } from 'vitest';

import path from 'node:path';
import { fileURLToPath } from 'node:url';

import { createFixture } from '../fixture.js';

const ARGV = ['node', './bin/betterer'];
Expand Down Expand Up @@ -34,9 +37,11 @@ describe('betterer cli', () => {

expect(attributesFile).toMatchSnapshot();

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(__dirname, '../../');
const gitconfigFile = await readFile(resolve('./.git/config'));

expect(gitconfigFile).toMatchSnapshot();
expect(gitconfigFile.replace(rootDir, '<root>')).toMatchSnapshot();

expect(logs).toMatchSnapshot();

Expand Down

0 comments on commit e857f86

Please sign in to comment.