Skip to content

Commit d217a1d

Browse files
committed
update script with more error logging
1 parent 181ecbb commit d217a1d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

scripts/isolated-demo-test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,27 @@ const processDemo = async (demoName: string): Promise<DemoResult> => {
7474
}
7575
};
7676

77-
const packageJSONPath = path.join(demoDest, 'package.json');
78-
const pkg = JSON.parse(await fs.readFile(packageJSONPath, 'utf-8'));
79-
8077
// Run pnpm install and pnpm build
8178
try {
8279
execSync('pnpm install', { cwd: demoDest, stdio: 'inherit' });
8380
result.installResult.state = TestState.PASSED;
8481
} catch (ex) {
82+
console.error('Error installing packages: ', ex);
8583
result.installResult.state = TestState.FAILED;
8684
result.installResult.error = ex.message;
8785
return result;
8886
}
8987

88+
const packageJSONPath = path.join(demoDest, 'package.json');
89+
const pkg = JSON.parse(await fs.readFile(packageJSONPath, 'utf-8'));
90+
9091
// Run pnpm clean for RN projects to avoid native build errors
9192
if (pkg.scripts['clean']) {
9293
try {
93-
execSync('pnpm clean', { cwd: demoDest, stdio: 'inherit' });
94+
execSync('pnpm run clean', { cwd: demoDest, stdio: 'inherit' });
9495
result.installResult.state = TestState.PASSED;
9596
} catch (ex) {
97+
console.error('Error running "pnpm run clean": ', ex);
9698
result.installResult.state = TestState.FAILED;
9799
result.installResult.error = ex.message;
98100
return result;
@@ -112,6 +114,7 @@ const processDemo = async (demoName: string): Promise<DemoResult> => {
112114
execSync('pnpm run test:build', { cwd: demoDest, stdio: 'inherit' });
113115
result.buildResult.state = TestState.PASSED;
114116
} catch (ex) {
117+
console.error('Error running "pnpm run "test:build": ', ex);
115118
result.buildResult.state = TestState.FAILED;
116119
result.buildResult.error = ex.message;
117120
}
@@ -149,9 +152,10 @@ const main = async () => {
149152
process.exit(1);
150153
}
151154

152-
const errored = !!results.find(
155+
const failed = results.filter(
153156
(r) => r.installResult.state == TestState.FAILED || r.buildResult.state == TestState.FAILED
154157
);
158+
const errored = failed.length > 0;
155159

156160
console.log(`Test results: \n${JSON.stringify(results, null, 2)}\n`);
157161

@@ -168,7 +172,10 @@ const main = async () => {
168172
.write();
169173

170174
if (errored) {
171-
console.error(`Some demos did not pass`);
175+
console.error('Some demos did not pass:');
176+
failed.forEach((r) =>
177+
console.error(`- ${r.name} (${r.buildResult.state === TestState.FAILED ? 'build' : 'install'})`)
178+
);
172179
process.exit(1);
173180
} else {
174181
console.log('All demos processed successfully.');

0 commit comments

Comments
 (0)