Skip to content

Commit ea2d898

Browse files
committed
add more debug statements
1 parent 71cebd9 commit ea2d898

File tree

1 file changed

+45
-3
lines changed
  • packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base

1 file changed

+45
-3
lines changed

packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base/commands.ts

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1961
const codegenPackagesInGen2 = [
2062
'@aws-amplify/graphql-generator',

0 commit comments

Comments
 (0)