-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-all-examples.js
More file actions
73 lines (61 loc) · 1.93 KB
/
run-all-examples.js
File metadata and controls
73 lines (61 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* Script to run all examples sequentially
* This ensures each example properly exits before starting the next one
*/
'use strict';
const { spawn } = require('child_process');
const path = require('path');
const examples = [
'src/examples/basicComparison.js',
'src/examples/advancedComparison.js',
'src/examples/passwordProtectedComparison.js',
'src/examples/streamComparison.js'
];
async function runExample(examplePath) {
return new Promise((resolve, reject) => {
console.log(`\n${'='.repeat(80)}`);
console.log(`Running: ${examplePath}`);
console.log('='.repeat(80));
const child = spawn('node', [examplePath], {
stdio: 'inherit',
shell: true
});
child.on('close', (code) => {
if (code === 0) {
console.log(`\n✓ ${examplePath} completed successfully\n`);
resolve();
} else {
console.error(`\n✗ ${examplePath} failed with exit code ${code}\n`);
reject(new Error(`Example ${examplePath} failed with exit code ${code}`));
}
});
child.on('error', (error) => {
console.error(`Error running ${examplePath}:`, error);
reject(error);
});
});
}
async function runAllExamples() {
console.log('\n🚀 Starting to run all examples...\n');
for (let i = 0; i < examples.length; i++) {
try {
await runExample(examples[i]);
// Small delay between examples to ensure cleanup
if (i < examples.length - 1) {
await new Promise(resolve => setTimeout(resolve, 1000));
}
} catch (error) {
console.error(`\n❌ Failed to run all examples. Stopped at: ${examples[i]}`);
console.error(error.message);
process.exit(1);
}
}
console.log('\n' + '='.repeat(80));
console.log('✅ All examples completed successfully!');
console.log('='.repeat(80) + '\n');
process.exit(0);
}
runAllExamples().catch((error) => {
console.error('Fatal error:', error);
process.exit(1);
});