mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 23:12:22 +03:00
Use __dirname to resolve path.
This commit is contained in:
parent
cf78609367
commit
d63ce72018
@ -1,13 +1,16 @@
|
||||
// const path = require("path");
|
||||
const path = require("path");
|
||||
|
||||
exports.handler = async function (event, context) {
|
||||
console.log(JSON.stringify(event));
|
||||
// process.chdir(path.join(__dirname, "../../"));
|
||||
// process.chdir("../");
|
||||
|
||||
// const compiledElmPath = path.join(process.cwd(), "elm-pages-cli.js");
|
||||
const compiledElmPath = path.join(__dirname, "elm-pages-cli.js");
|
||||
const renderer = require("../../../../generator/src/render");
|
||||
console.log("pwd", process.cwd());
|
||||
return {
|
||||
body: (await renderer()).htmlString,
|
||||
body: (await renderer(compiledElmPath)).htmlString,
|
||||
statusCode: 200,
|
||||
};
|
||||
};
|
||||
|
@ -15,14 +15,17 @@ process.on("unhandledRejection", (error) => {
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
module.exports = async function run() {
|
||||
module.exports = async function run(/** @type {string} */ compiledElmPath) {
|
||||
XMLHttpRequest = require("xhr2");
|
||||
console.log("RENDER NEW");
|
||||
const result = await runElmApp();
|
||||
const result = await runElmApp(compiledElmPath);
|
||||
return result;
|
||||
};
|
||||
|
||||
function runElmApp() {
|
||||
/**
|
||||
* @param {string} compiledElmPath
|
||||
*/
|
||||
function runElmApp(compiledElmPath) {
|
||||
process.on("beforeExit", (code) => {
|
||||
if (foundErrors) {
|
||||
process.exit(1);
|
||||
@ -32,10 +35,9 @@ function runElmApp() {
|
||||
});
|
||||
|
||||
return new Promise((resolve, _) => {
|
||||
const ELM_FILE_PATH = path.join(process.cwd(), "elm-pages-cli.js");
|
||||
const mode /** @type { "dev" | "prod" } */ = "elm-to-html-beta";
|
||||
const staticHttpCache = {};
|
||||
const app = require(ELM_FILE_PATH).Elm.Main.init({
|
||||
const app = require(compiledElmPath).Elm.Main.init({
|
||||
flags: { secrets: process.env, mode, staticHttpCache },
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user