1313 * npm run hooks:generate -- --list # List available product IDs
1414 *
1515 * Prerequisites:
16- * - wp-hooks-documentor installed globally : npm i -g github:GravityKit/wp-hooks-documentor
16+ * - Dependencies installed: npm install
1717 * - Repos cloned via: npm run repos:clone
1818 */
1919
@@ -109,17 +109,17 @@ function loadConfig() {
109109}
110110
111111/**
112- * Check if wp-hooks-documentor is available
112+ * Check if wp-hooks-documentor is available (via npx for local install)
113113 */
114114function checkWpHooksDocumentor ( ) {
115- // Try --help first as it's more universally supported than --version
116- const result = spawnSync ( 'wp-hooks-documentor' , [ '--help' ] , {
115+ // Try running via npx which finds locally installed packages
116+ const result = spawnSync ( 'npx' , [ ' wp-hooks-documentor', '--help' ] , {
117117 encoding : 'utf8' ,
118118 stdio : 'pipe' ,
119119 } ) ;
120120
121121 // If no error running the command, the tool is available
122- if ( ! result . error ) {
122+ if ( ! result . error && result . status === 0 ) {
123123 return true ;
124124 }
125125 return false ;
@@ -269,8 +269,8 @@ function generateHooksDocs(product, config, options) {
269269 const configPath = path . join ( tempWorkDir , 'wp-hooks-doc.json' ) ;
270270 fs . writeFileSync ( configPath , JSON . stringify ( hooksConfig , null , 2 ) ) ;
271271
272- // Run wp-hooks-documentor from the temp directory
273- const result = spawnSync ( 'wp-hooks-documentor' , [ 'generate' , '--skip-build' ] , {
272+ // Run wp-hooks-documentor via npx from the temp directory
273+ const result = spawnSync ( 'npx' , [ ' wp-hooks-documentor', 'generate' , '--skip-build' ] , {
274274 cwd : tempWorkDir ,
275275 stdio : 'inherit' ,
276276 shell : false ,
@@ -281,7 +281,7 @@ function generateHooksDocs(product, config, options) {
281281 return {
282282 ok : false ,
283283 id : product . id ,
284- reason : 'wp-hooks-documentor not found. Install : npm i -g github:GravityKit/wp-hooks-documentor ' ,
284+ reason : 'wp-hooks-documentor not found. Run : npm install ' ,
285285 } ;
286286 }
287287 return {
@@ -591,7 +591,7 @@ ${colors.cyan}Examples:${colors.reset}
591591 npm run hooks:generate -- --dry-run # Preview mode
592592
593593${ colors . cyan } Prerequisites:${ colors . reset }
594- 1. Install wp-hooks-documentor : npm i -g github:GravityKit/wp-hooks-documentor
594+ 1. Install dependencies : npm install
595595 2. Clone repositories: npm run repos:clone
596596
597597${ colors . cyan } Output:${ colors . reset }
@@ -643,8 +643,8 @@ async function main() {
643643 logStep ( 'Checking prerequisites' ) ;
644644
645645 if ( ! checkWpHooksDocumentor ( ) ) {
646- logError ( 'wp-hooks-documentor is not installed or not in PATH ' ) ;
647- logInfo ( 'Install it with : npm i -g github:GravityKit/wp-hooks-documentor ' ) ;
646+ logError ( 'wp-hooks-documentor is not installed' ) ;
647+ logInfo ( 'Run : npm install ' ) ;
648648 return 1 ;
649649 }
650650 logSuccess ( 'wp-hooks-documentor is available' ) ;
0 commit comments