Makelore 2.0 initial clean snapshot
This commit is contained in:
52
scripts/run-electron-vitest.mjs
Normal file
52
scripts/run-electron-vitest.mjs
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const rawArgs = process.argv.slice(2);
|
||||
const verifyReleaseRuntime = rawArgs.includes('--verify-release-runtime');
|
||||
const vitestArgs = rawArgs.filter(
|
||||
(arg) => arg !== '--verify-release-runtime' && arg !== '--',
|
||||
);
|
||||
|
||||
const electronExecutable = require('electron');
|
||||
const electronPackagePath = require.resolve('electron/package.json');
|
||||
const electronPackage = JSON.parse(readFileSync(electronPackagePath, 'utf8'));
|
||||
const vitestPackagePath = require.resolve('vitest/package.json');
|
||||
const vitestCli = join(dirname(vitestPackagePath), 'vitest.mjs');
|
||||
const result = spawnSync(electronExecutable, [
|
||||
vitestCli,
|
||||
'run',
|
||||
'--config',
|
||||
join(root, 'vitest.electron.config.ts'),
|
||||
...vitestArgs,
|
||||
], {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
env: {
|
||||
...process.env,
|
||||
ELECTRON_RUN_AS_NODE: '1',
|
||||
NIANCODE_LOCAL_ELECTRON_VERSION: electronPackage.version,
|
||||
...(verifyReleaseRuntime ? { NIANCODE_VERIFY_RELEASE_RUNTIME: '1' } : {}),
|
||||
},
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
console.error('[electron-runtime] failed to start Electron:', result.error);
|
||||
process.exit(1);
|
||||
}
|
||||
if (result.signal) {
|
||||
console.error(`[electron-runtime] Electron ended by signal ${result.signal}`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (result.status === null) {
|
||||
console.error('[electron-runtime] Electron returned no exit status');
|
||||
process.exit(1);
|
||||
}
|
||||
process.exit(result.status);
|
||||
Reference in New Issue
Block a user