UNPKG

buckshotplusplus

Version:

BuckshotPlusPlus - A simple and efficient web development language

51 lines (42 loc) 1.39 kB
#!/usr/bin/env node const path = require('path'); const { spawn } = require('child_process'); const os = require('os'); const fs = require('fs'); const platform = os.platform(); const arch = os.arch(); const getBinaryDir = () => { const platformDir = `${platform}-${arch}`; return path.join(__dirname, '..', 'lib', 'binaries', platformDir, platformDir); }; const binaryDir = getBinaryDir(); const binaryName = platform === 'win32' ? 'BuckshotPlusPlus.exe' : 'BuckshotPlusPlus'; const binaryPath = path.join(binaryDir, binaryName); // Check if the binary exists if (!fs.existsSync(binaryPath)) { console.error(`Error: Binary not found at ${binaryPath}`); process.exit(1); } const args = process.argv.slice(2).map(arg => { // If the argument looks like a file path, convert it to absolute if (arg.endsWith('.bpp')) { const absolutePath = path.resolve(process.cwd(), arg); if (!fs.existsSync(absolutePath)) { console.error(`Error: File not found: ${arg}`); process.exit(1); } return absolutePath; } return arg; }); const bppProcess = spawn(binaryPath, args, { stdio: 'inherit', cwd: process.cwd() }); bppProcess.on('error', (err) => { console.error(`Failed to start BuckshotPlusPlus: ${err.message}`); process.exit(1); }); bppProcess.on('exit', (code) => { process.exit(code); });