-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-cli.js
More file actions
40 lines (31 loc) · 1.12 KB
/
test-cli.js
File metadata and controls
40 lines (31 loc) · 1.12 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
import { execa } from 'execa';
import fs from 'fs/promises';
import path from 'path';
async function testCLI() {
console.log('Testing CreateForge CLI...');
// Create a test directory
const testDir = path.join(process.cwd(), 'test-project');
try {
// Clean up if test directory exists
await fs.rm(testDir, { recursive: true, force: true });
console.log('✓ Test environment cleaned');
// Test CLI help command
const helpResult = await execa('node', ['dist/cli.js', '--help'], { cwd: process.cwd() });
console.log('✓ CLI help command works');
// Test CLI version command
const versionResult = await execa('node', ['dist/cli.js', '--version'], { cwd: process.cwd() });
console.log('✓ CLI version command works:', versionResult.stdout);
console.log('\n🎉 All CLI tests passed!');
} catch (error) {
console.error('❌ Test failed:', error.message);
process.exit(1);
} finally {
// Clean up test directory
try {
await fs.rm(testDir, { recursive: true, force: true });
} catch (e) {
// Ignore cleanup errors
}
}
}
testCLI();