Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/thatstupidcomputer / scripts/preview.mjs |
| Date | Not specified in source |
| Repository | Janady13/thatstupidcomputer |
| Revision | 57555cde46910102dd25d6c1c1fb2c359e9655bd |
| Branch | main |
| Path or archive member | scripts/preview.mjs |
| Original SHA-256 | a90cb40c353822ab1296d4db816c32de62d469b812901a55375021d04a474236 |
| Git blob SHA | eee095ea8e8d523076df5a7dac493a190ce31c24 |
| Reading-copy SHA-256 | a90cb40c353822ab1296d4db816c32de62d469b812901a55375021d04a474236 |
Recovered source transcript
Download complete source text ↓19 lines · 1.0 KB
import { spawn } from 'node:child_process';
import { existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
const root = fileURLToPath(new URL('..', import.meta.url));
process.chdir(root);
if (!existsSync('apps/api/dist/server.mjs') || !existsSync('apps/web/dist/index.html')) throw new Error('Run npm run build before preview.');
if (existsSync('.env')) process.loadEnvFile('.env');
const port = process.env.PREVIEW_PORT || '4173';
const child = spawn(process.execPath, ['apps/api/dist/server.mjs'], {
cwd: root, stdio: 'inherit', env: {
...process.env, NODE_ENV: 'development', HOST: '127.0.0.1', PORT: port,
PUBLIC_ORIGIN: `http://localhost:${port}`, ALLOWED_ORIGINS: `http://localhost:${port},http://127.0.0.1:${port}`,
},
});
process.on('SIGINT', () => child.kill('SIGINT'));
process.on('SIGTERM', () => child.kill('SIGTERM'));
child.on('error', error => { console.error(error.message); process.exitCode = 1; });
child.on('exit', code => { process.exitCode = code || 0; });