mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-08 02:03:34 +08:00
fix: resolve ESLint errors and add npx command support in hook tests
Remove unused loadInstallManifests import and prefix unused result variable with underscore in selective-install tests. Add npx as an approved command prefix in hook validation tests.
This commit is contained in:
@@ -1782,10 +1782,11 @@ async function runTests() {
|
|||||||
for (const hook of entry.hooks) {
|
for (const hook of entry.hooks) {
|
||||||
if (hook.type === 'command') {
|
if (hook.type === 'command') {
|
||||||
const isNode = hook.command.startsWith('node');
|
const isNode = hook.command.startsWith('node');
|
||||||
|
const isNpx = hook.command.startsWith('npx ');
|
||||||
const isSkillScript = hook.command.includes('/skills/') && (/^(bash|sh)\s/.test(hook.command) || hook.command.startsWith('${CLAUDE_PLUGIN_ROOT}/skills/'));
|
const isSkillScript = hook.command.includes('/skills/') && (/^(bash|sh)\s/.test(hook.command) || hook.command.startsWith('${CLAUDE_PLUGIN_ROOT}/skills/'));
|
||||||
const isHookShellWrapper = /^(bash|sh)\s+["']?\$\{CLAUDE_PLUGIN_ROOT\}\/scripts\/hooks\/run-with-flags-shell\.sh/.test(hook.command);
|
const isHookShellWrapper = /^(bash|sh)\s+["']?\$\{CLAUDE_PLUGIN_ROOT\}\/scripts\/hooks\/run-with-flags-shell\.sh/.test(hook.command);
|
||||||
const isSessionStartFallback = hook.command.startsWith('bash -lc') && hook.command.includes('run-with-flags.js');
|
const isSessionStartFallback = hook.command.startsWith('bash -lc') && hook.command.includes('run-with-flags.js');
|
||||||
assert.ok(isNode || isSkillScript || isHookShellWrapper || isSessionStartFallback, `Hook command should use node or approved shell wrapper: ${hook.command.substring(0, 100)}...`);
|
assert.ok(isNode || isNpx || isSkillScript || isHookShellWrapper || isSessionStartFallback, `Hook command should use node or approved shell wrapper: ${hook.command.substring(0, 100)}...`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -673,6 +673,7 @@ async function runTests() {
|
|||||||
|
|
||||||
const isInline = hook.command.startsWith('node -e');
|
const isInline = hook.command.startsWith('node -e');
|
||||||
const isFilePath = hook.command.startsWith('node "');
|
const isFilePath = hook.command.startsWith('node "');
|
||||||
|
const isNpx = hook.command.startsWith('npx ');
|
||||||
const isShellWrapper =
|
const isShellWrapper =
|
||||||
hook.command.startsWith('bash "') ||
|
hook.command.startsWith('bash "') ||
|
||||||
hook.command.startsWith('sh "') ||
|
hook.command.startsWith('sh "') ||
|
||||||
@@ -681,8 +682,8 @@ async function runTests() {
|
|||||||
const isShellScriptPath = hook.command.endsWith('.sh');
|
const isShellScriptPath = hook.command.endsWith('.sh');
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
isInline || isFilePath || isShellWrapper || isShellScriptPath,
|
isInline || isFilePath || isNpx || isShellWrapper || isShellScriptPath,
|
||||||
`Hook command in ${hookType} should be node -e, node script, or shell wrapper/script, got: ${hook.command.substring(0, 80)}`
|
`Hook command in ${hookType} should be node -e, node script, npx, or shell wrapper/script, got: ${hook.command.substring(0, 80)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ const {
|
|||||||
} = require('../../scripts/lib/install/request');
|
} = require('../../scripts/lib/install/request');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
loadInstallManifests,
|
|
||||||
listInstallComponents,
|
listInstallComponents,
|
||||||
resolveInstallPlan,
|
resolveInstallPlan,
|
||||||
} = require('../../scripts/lib/install-manifests');
|
} = require('../../scripts/lib/install-manifests');
|
||||||
@@ -564,7 +563,7 @@ function runTests() {
|
|||||||
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'selective-install-project-'));
|
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'selective-install-project-'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = execFileSync('node', [
|
const _result = execFileSync('node', [
|
||||||
scriptPath,
|
scriptPath,
|
||||||
'--profile', 'core',
|
'--profile', 'core',
|
||||||
'--with', 'capability:security',
|
'--with', 'capability:security',
|
||||||
|
|||||||
Reference in New Issue
Block a user