u
This commit is contained in:
43
src/sea-entry.cjs
Normal file
43
src/sea-entry.cjs
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* SEA Entry point for dashback.
|
||||
* Injected into the Node.js single executable binary via node --build-sea.
|
||||
*
|
||||
* When launched as a SEA binary, it resolves the project root,
|
||||
* configures module resolution, and loads src/index.js.
|
||||
*/
|
||||
const { createRequire } = require('node:module');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
|
||||
function resolveProjectRoot() {
|
||||
if (process.env.DASHBACK_ROOT && fs.existsSync(path.join(process.env.DASHBACK_ROOT, 'src/index.js'))) {
|
||||
return path.resolve(process.env.DASHBACK_ROOT);
|
||||
}
|
||||
const cwdEntry = path.join(process.cwd(), 'src/index.js');
|
||||
if (fs.existsSync(cwdEntry)) {
|
||||
return process.cwd();
|
||||
}
|
||||
const parentEntry = path.join(__dirname, '..', 'src/index.js');
|
||||
if (fs.existsSync(parentEntry)) {
|
||||
return path.resolve(__dirname, '..');
|
||||
}
|
||||
const dirEntry = path.join(__dirname, 'src/index.js');
|
||||
if (fs.existsSync(dirEntry)) {
|
||||
return __dirname;
|
||||
}
|
||||
return process.cwd();
|
||||
}
|
||||
|
||||
const projectRoot = resolveProjectRoot();
|
||||
const entryFile = path.join(projectRoot, 'src/index.js');
|
||||
|
||||
if (!fs.existsSync(entryFile)) {
|
||||
console.error(`[SEA] Could not find dashback entry point at ${entryFile}.`);
|
||||
console.error(`[SEA] Please ensure you are running from the dashback repository root or set DASHBACK_ROOT.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.argv[1] = entryFile;
|
||||
|
||||
const req = createRequire(entryFile);
|
||||
req(entryFile);
|
||||
Reference in New Issue
Block a user