-
Notifications
You must be signed in to change notification settings - Fork 8
64 lines (57 loc) · 1.96 KB
/
Copy pathtest.yml
File metadata and controls
64 lines (57 loc) · 1.96 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
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Syntax check all source files
run: |
for file in $(find src -name "*.js" | sort); do
echo "Checking $file..."
node -c "$file"
done
echo "All files passed syntax check."
- name: Validate command structure
run: |
node -e "
const fs = require('fs');
const path = require('path');
const commandsDir = path.resolve('src/commands');
const files = fs.readdirSync(commandsDir).filter(f => f.endsWith('.js'));
let ok = true;
for (const file of files) {
const content = fs.readFileSync(path.resolve(commandsDir, file), 'utf-8');
const hasData = /\bdata\s*[:=]/.test(content);
const hasExecute = /async\s+execute\b|\.execute\s*=/.test(content);
if (!hasData) {
console.error('FAIL: ' + file + ' — missing \"data\"');
ok = false;
}
if (!hasExecute) {
console.error('FAIL: ' + file + ' — missing \"execute\"');
ok = false;
}
if (hasData && hasExecute) {
const name = content.match(/setName\(['\"](\w+)['\"]\)/);
console.log('OK: ' + file + (name ? ' — /' + name[1] : ''));
}
}
if (!ok) process.exit(1);
console.log('All ' + files.length + ' commands validated.');
"