varan
Version:
A webpack starter kit for offline-first bring-your-own-code apps with server side rendering
33 lines • 1.28 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const execa_1 = __importDefault(require("execa"));
// Init
const getOpts = (options) => lodash_1.defaults({}, options, {
args: [],
waitForPromise: null,
});
// Exports
async function runServer(options) {
const opts = getOpts(options);
const launchArgs = opts.args;
// Pass in arguments to child
const debugArgs = [
...new Set(launchArgs
.concat(process.env.NODE_DEBUG_OPTION || [])
.filter((arg) => arg.startsWith('--inspect') || arg.startsWith('--debug'))),
];
const debugPort = debugArgs.length > 0 ? process.debugPort + 1 : process.debugPort;
const execArgs = launchArgs
.filter((arg) => !debugArgs.includes(arg))
.concat(debugArgs.map((arg) => arg.replace(process.debugPort.toString(), debugPort.toString())));
if (opts.waitForPromise)
await opts.waitForPromise;
const server = execa_1.default('node', execArgs.concat(opts.entry));
return { server };
}
exports.default = runServer;
//# sourceMappingURL=runServer.js.map