mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-01 07:45:22 +03:00
Switch back to original dir after running elm, and export function.
This commit is contained in:
parent
c022531ff2
commit
68b6ceb769
@ -1,12 +1,22 @@
|
||||
var compile = require("node-elm-compiler").compile;
|
||||
var compileToString = require("node-elm-compiler").compileToString;
|
||||
const { compileToString } = require("node-elm-compiler");
|
||||
|
||||
process.chdir("./examples/docs/");
|
||||
compileToString(["./src/Main.elm"], {}).then(function(data) {
|
||||
eval(data.toString());
|
||||
const app = Elm.Main.init({ flags: { imageAssets: {} } });
|
||||
module.exports = runElm;
|
||||
function runElm(callback) {
|
||||
const startingDir = process.cwd();
|
||||
console.log("cwd", process.cwd());
|
||||
process.chdir("./examples/docs/");
|
||||
console.log("cwd", process.cwd());
|
||||
compileToString(["./src/Main.elm"], {}).then(function(data) {
|
||||
eval(data.toString());
|
||||
const app = Elm.Main.init({ flags: { imageAssets: {} } });
|
||||
|
||||
app.ports.toJsPort.subscribe(payload => {
|
||||
console.log("payload", payload);
|
||||
app.ports.toJsPort.subscribe(payload => {
|
||||
console.log("payload", payload);
|
||||
callback(payload);
|
||||
process.chdir(startingDir);
|
||||
console.log("cwd", process.cwd());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
runElm(function() {});
|
||||
|
Loading…
Reference in New Issue
Block a user