mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(ci): make portless optional for windows installs
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { spawn } from 'node:child_process';
|
||||
|
||||
const isWindows = process.platform === 'win32';
|
||||
const usePortless = process.env.PORTLESS !== '0' && !isWindows;
|
||||
const binDir = join(process.cwd(), 'node_modules', '.bin');
|
||||
const executableSuffix = isWindows ? '.cmd' : '';
|
||||
const portlessBin = join(binDir, `portless${executableSuffix}`);
|
||||
const viteBin = join(binDir, `vite${executableSuffix}`);
|
||||
|
||||
const command = usePortless && existsSync(portlessBin) ? portlessBin : viteBin;
|
||||
const args =
|
||||
command === portlessBin
|
||||
? ['5chan', 'vite']
|
||||
: ['--host', '5chan.localhost', '--port', '1355', '--strictPort'];
|
||||
|
||||
if (command !== portlessBin && process.env.PORTLESS !== '0') {
|
||||
console.warn('portless unavailable on this platform, using vite directly on http://5chan.localhost:1355');
|
||||
}
|
||||
|
||||
const child = spawn(command, args, {
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
});
|
||||
|
||||
child.on('exit', (code, signal) => {
|
||||
if (signal) {
|
||||
process.kill(process.pid, signal);
|
||||
return;
|
||||
}
|
||||
|
||||
process.exit(code ?? 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user