-
Notifications
You must be signed in to change notification settings - Fork 0
/
nitro.js
27 lines (21 loc) · 863 Bytes
/
nitro.js
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
#!/usr/bin/env node
const { spawn } = require('child_process');
const path = require('path');
// Determine the path of nitro or nitro.exe depending on the operating system
const nitroExecutable = process.platform === 'win32' ? 'nitro.exe' : 'nitro';
const nitroPath = path.join(__dirname, nitroExecutable);
// Get the arguments passed to this script
const args = process.argv.slice(2);
// Create a child process to run the nitro file
const child = spawn(nitroPath, args, {
cwd: __dirname, // Set the working directory to __dirname
stdio: 'inherit' // Inherit stdin, stdout, and stderr from the current process
});
// Handle the child process's exit
child.on('close', (code) => {
console.log(`Child process exited with code ${code}`);
});
// Handle errors
child.on('error', (err) => {
console.error('Failed to start child process:', err);
});