-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdev-server.js
More file actions
48 lines (37 loc) · 1.2 KB
/
dev-server.js
File metadata and controls
48 lines (37 loc) · 1.2 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
#!/usr/bin/env node
const { spawn } = require('child_process');
const fs = require('fs');
const path = require('path');
const projectRoot = path.resolve(__dirname, '..');
function loadServerOnlyFileWatching() {
const settingsPath = process.env.ORCHESTRATOR_USER_SETTINGS_PATH
|| path.join(projectRoot, 'user-settings.json');
try {
if (fs.existsSync(settingsPath)) {
const data = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
return data?.global?.serverOnlyFileWatching === true;
}
} catch {
// Fall through to default
}
return false;
}
const serverOnly = loadServerOnlyFileWatching();
const nodemonBin = path.join(projectRoot, 'node_modules', '.bin', 'nodemon');
const args = [];
if (serverOnly) {
// Explicit watch list overrides nodemon.json watch config
args.push('--watch', 'server/', '--watch', '.env');
}
args.push('server/index.js');
if (process.argv.includes('--dry-run')) {
console.log('serverOnlyFileWatching:', serverOnly);
console.log('command:', nodemonBin, args.join(' '));
process.exit(0);
}
const child = spawn(nodemonBin, args, {
cwd: projectRoot,
stdio: 'inherit',
env: process.env
});
child.on('exit', (code) => process.exit(code ?? 1));