-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathstart-dev.js
More file actions
46 lines (42 loc) · 1.4 KB
/
start-dev.js
File metadata and controls
46 lines (42 loc) · 1.4 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
const { spawn } = require('child_process');
const path = require('path');
// Override console.warn to filter out specific warnings
const originalWarn = console.warn;
console.warn = function(...args) {
const message = args.join(' ');
if (
message.includes('onAfterSetupMiddleware') ||
message.includes('onBeforeSetupMiddleware') ||
message.includes("'onAfterSetupMiddleware' option is deprecated") ||
message.includes("'onBeforeSetupMiddleware' option is deprecated")
) {
return; // Suppress these specific warnings
}
return originalWarn.apply(console, arguments);
};
// Override process.emit to catch deprecation warnings
const originalEmit = process.emit;
process.emit = function(name, data, ...args) {
if (
name === 'warning' &&
typeof data === 'object' &&
data.name === 'DeprecationWarning' &&
(data.message.includes('onAfterSetupMiddleware') ||
data.message.includes('onBeforeSetupMiddleware'))
) {
return false; // Suppress the warning
}
return originalEmit.apply(process, arguments);
};
// Start react-scripts - Use the actual JS file on Windows
const reactScriptsPath = path.join(__dirname, 'node_modules', 'react-scripts', 'bin', 'react-scripts.js');
const child = spawn('node', [reactScriptsPath, 'start'], {
stdio: 'inherit',
env: {
...process.env,
GENERATE_SOURCEMAP: 'false'
}
});
child.on('exit', (code) => {
process.exit(code);
});