mirror of
https://github.com/ziex-dev/ziex.git
synced 2026-07-22 11:39:34 -06:00
26 lines
854 B
JavaScript
Executable File
26 lines
854 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
import { spawn } from 'node:child_process';
|
|
import { createRequire } from 'node:module';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const pkgName = `@ziex/cli-${process.platform}-${process.arch}`;
|
|
const ext = process.platform === 'win32' ? '.exe' : '';
|
|
|
|
try {
|
|
const binaryPath = require.resolve(`${pkgName}/bin/zx${ext}`);
|
|
|
|
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
stdio: 'inherit',
|
|
shell: process.platform === 'win32'
|
|
});
|
|
|
|
child.on('exit', (code) => process.exit(code ?? 0));
|
|
child.on('error', (err) => {
|
|
console.error('Failed to start child process:', err);
|
|
process.exit(1);
|
|
});
|
|
} catch (e) {
|
|
console.error(`Error: Could not find binary for ${process.platform}-${process.arch}`);
|
|
console.error(`Ensure the optional dependency "${pkgName}" is installed.`);
|
|
process.exit(1);
|
|
} |