Skip to content

Commit 11e7824

Browse files
committed
fix(rstack): clarify forced setup output
1 parent 21550c4 commit 11e7824

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

‎packages/rstack/src/setup/index.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,24 @@ export const runSetupCLI = async (args: string[]): Promise<void> => {
3232
const result = installHooks({ force: values.force, hooksDir });
3333

3434
if (result.status === 'installed') {
35-
// Warn when `--force` preserves an existing hooks setup but makes it inactive.
35+
// Explain the result when `--force` preserves an existing hooks setup but makes it inactive.
3636
if (result.inactiveHooks) {
3737
const { hooks, path, restore } = result.inactiveHooks;
3838
const hooksMessage = hooks.length
3939
? `: ${color.yellow(hooks.join(', '))}`
4040
: '';
41-
logger.warn(
42-
`The previous Git hooks path "${color.yellow(path)}" is now inactive${hooksMessage}.`,
41+
logger.info(
42+
`Rstack now manages Git hooks at "${color.yellow(result.hooksPath)}".`,
43+
);
44+
logger.info(
45+
`Existing hooks in "${color.yellow(path)}" were preserved but will no longer run${hooksMessage}.`,
4346
);
4447

4548
if (restore === 'unset') {
46-
logger.info(
47-
`The existing files were preserved and will become active again if ${color.yellow('core.hooksPath')} is unset.`,
48-
);
49+
logger.info(`Unset ${color.yellow('core.hooksPath')} to restore them.`);
4950
} else {
5051
logger.info(
51-
`The existing files were preserved. Set ${color.yellow('core.hooksPath')} back to this path to use them again.`,
52+
`Set ${color.yellow('core.hooksPath')} back to "${color.yellow(path)}" to restore them.`,
5253
);
5354
}
5455
}

‎packages/rstack/tests/cli/setup/index.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,12 @@ test('guides and forces setup while preserving existing hooks', ({
140140

141141
const forcedOutput = runSetupSuccessfully(['--force']);
142142
expect(forcedOutput).toContain(
143-
'The previous Git hooks path ".git/hooks" is now inactive: pre-commit.',
143+
'info Rstack now manages Git hooks at ".rstack/hooks/_".',
144144
);
145145
expect(forcedOutput).toContain(
146-
'The existing files were preserved and will become active again if core.hooksPath is unset.',
146+
'Existing hooks in ".git/hooks" were preserved but will no longer run: pre-commit.',
147147
);
148+
expect(forcedOutput).toContain('Unset core.hooksPath to restore them.');
148149
expect(git(['config', '--local', '--get', 'core.hooksPath'])).toBe(hooksPath);
149150

150151
git(['hook', 'run', 'pre-commit']);
@@ -155,7 +156,7 @@ test('guides and forces setup while preserving existing hooks', ({
155156
expect(existsSync(path.join(cwd, 'old-hook-ran'))).toBe(true);
156157

157158
expect(runSetupSuccessfully(['-f'])).toContain(
158-
'The previous Git hooks path ".git/hooks" is now inactive: pre-commit.',
159+
'Existing hooks in ".git/hooks" were preserved but will no longer run: pre-commit.',
159160
);
160161
});
161162

@@ -171,10 +172,13 @@ test('reports how to restore a replaced hooks path', ({ expect }) => {
171172

172173
const output = runSetupSuccessfully(['--force']);
173174
expect(output).toContain(
174-
'The previous Git hooks path ".husky/_" is now inactive: pre-commit.',
175+
'info Rstack now manages Git hooks at ".rstack/hooks/_".',
175176
);
176177
expect(output).toContain(
177-
'The existing files were preserved. Set core.hooksPath back to this path to use them again.',
178+
'Existing hooks in ".husky/_" were preserved but will no longer run: pre-commit.',
179+
);
180+
expect(output).toContain(
181+
'Set core.hooksPath back to ".husky/_" to restore them.',
178182
);
179183
});
180184

0 commit comments

Comments
 (0)