Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugin/hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"hooks": {
"Setup": [
{
"_comment": "Uses smart-install.js (not setup.sh which was deleted in 74d94aa2). See #1268.",
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "_R=\"${CLAUDE_PLUGIN_ROOT}\"; [ -z \"$_R\" ] && _R=\"$HOME/.claude/plugins/marketplaces/thedotmack/plugin\"; \"$_R/scripts/setup.sh\"",
"command": "_R=\"${CLAUDE_PLUGIN_ROOT}\"; [ -z \"$_R\" ] && _R=\"$HOME/.claude/plugins/marketplaces/thedotmack/plugin\"; node \"$_R/scripts/smart-install.js\"",
"timeout": 300
}
]
Expand Down
38 changes: 38 additions & 0 deletions tests/smart-install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,41 @@ describe('smart-install verifyCriticalModules logic', () => {
expect(missing).toEqual(['@chroma-core/other-pkg']);
});
});

describe('hooks.json Setup hook (#1268)', () => {
const hooksJsonPath = join(__dirname, '..', 'plugin', 'hooks', 'hooks.json');

it('should reference an existing script in the Setup hook', () => {
const hooksJson = JSON.parse(readFileSync(hooksJsonPath, 'utf-8'));
const setupHooks = hooksJson.hooks?.Setup;
expect(setupHooks).toBeDefined();
expect(setupHooks.length).toBeGreaterThan(0);

const setupCommand: string = setupHooks[0].hooks[0].command;

// Extract the script path from the hook command.
// Format: _R="..."; [ -z "$_R" ] && _R="..."; node "$_R/scripts/<script>"
// The script name is the last path component after /scripts/
const scriptMatch = setupCommand.match(/scripts\/([^\s"]+)/);
expect(scriptMatch).not.toBeNull();

const scriptName = scriptMatch![1];
const scriptPath = join(__dirname, '..', 'plugin', 'scripts', scriptName);

expect(existsSync(scriptPath)).toBe(true);
});

it('should not reference the deleted setup.sh script', () => {
const hooksJson = JSON.parse(readFileSync(hooksJsonPath, 'utf-8'));
const setupCommand: string = hooksJson.hooks.Setup[0].hooks[0].command;

expect(setupCommand).not.toContain('setup.sh');
});

it('should reference smart-install.js which handles all setup tasks', () => {
const hooksJson = JSON.parse(readFileSync(hooksJsonPath, 'utf-8'));
const setupCommand: string = hooksJson.hooks.Setup[0].hooks[0].command;

expect(setupCommand).toContain('smart-install.js');
});
});