@@ -7,14 +7,56 @@ import { spawnSync } from 'child_process';
77 * Retrieve the path to the `npx` executable for interacting with the amplify gen2 cli.
88 * @returns the local `npx` executable path.
99 */
10- const getNpxPath = ( ) : string => ( process . platform === 'win32' ? getScriptRunnerPath ( ) . replace ( 'node.exe' , 'npx.cmd' ) : 'npx' ) ;
10+ const getNpxPath = ( ) : string => {
11+ console . log ( `DEBUG: process.platform is: ${ process . platform } ` ) ;
12+ if ( process . platform === 'win32' ) {
13+ const scriptRunnerPath = getScriptRunnerPath ( ) ;
14+ console . log ( `DEBUG: getScriptRunnerPath() returned: ${ scriptRunnerPath } ` ) ;
15+ const npxPath = scriptRunnerPath . replace ( 'node.exe' , 'npx.cmd' ) ;
16+ console . log ( `DEBUG: Resolved npxPath for Windows: ${ npxPath } ` ) ;
17+ return npxPath ;
18+ } else {
19+ console . log ( `DEBUG: Non-Windows platform; using 'npx'` ) ;
20+ return 'npx' ;
21+ }
22+ } ;
23+
1124/**
1225 * Retrieve the path to the `ampx` executable for interacting with the amplify gen2 cli.
1326 * @param cwd current working directory
1427 * @returns the local `ampx` executable path
1528 */
16- const getAmpxPath = ( cwd : string ) : string =>
17- spawnSync ( getNpxPath ( ) , [ 'which' , 'ampx' ] , { cwd, env : process . env , stdio : 'pipe' } ) . stdout . toString ( ) . trim ( ) ;
29+ const getAmpxPath = ( cwd : string ) : string => {
30+ // Retrieve the path to npx
31+ const npxPath = getNpxPath ( ) ;
32+ console . log ( `DEBUG: Resolved npx path: ${ npxPath } ` ) ;
33+
34+ // Execute the command to find 'ampx'
35+ const spawnResult = spawnSync ( npxPath , [ 'which' , 'ampx' ] , { cwd, env : process . env , stdio : 'pipe' } ) ;
36+
37+ // Log the entire result of spawnSync for inspection
38+ console . log ( 'DEBUG: spawnSync result:' , spawnResult ) ;
39+
40+ if ( spawnResult . error ) {
41+ console . error ( 'DEBUG: spawnSync encountered an error:' , spawnResult . error ) ;
42+ }
43+
44+ // Log stderr if available
45+ if ( spawnResult . stderr ) {
46+ console . error ( 'DEBUG: spawnSync stderr:' , spawnResult . stderr . toString ( ) ) ;
47+ }
48+
49+ // Ensure stdout exists before converting to string
50+ const stdout = spawnResult . stdout ;
51+ if ( ! stdout ) {
52+ console . error ( 'DEBUG: No stdout received from spawnSync.' ) ;
53+ return '' ;
54+ }
55+
56+ const result = stdout . toString ( ) . trim ( ) ;
57+ console . log ( `DEBUG: Parsed output: "${ result } "` ) ;
58+ return result ;
59+ } ;
1860
1961const codegenPackagesInGen2 = [
2062 '@aws-amplify/graphql-generator' ,
0 commit comments