mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-30 23:06:10 +03:00
Prevent errors when watcher re-runs and tries to evaluate Elm with Elm value in namespace.
This commit is contained in:
parent
2bdf4da5d7
commit
1310f5cbea
@ -7,12 +7,15 @@ function runElm(callback) {
|
||||
const startingDir = process.cwd();
|
||||
process.chdir(elmBaseDirectory);
|
||||
compileToString([mainElmFile], {}).then(function(data) {
|
||||
eval(data.toString());
|
||||
const app = Elm.Main.init({ flags: { imageAssets: {} } });
|
||||
(function() {
|
||||
eval(data.toString());
|
||||
const app = Elm.Main.init({ flags: { imageAssets: {} } });
|
||||
|
||||
app.ports.toJsPort.subscribe(payload => {
|
||||
process.chdir(startingDir);
|
||||
callback(payload);
|
||||
});
|
||||
app.ports.toJsPort.subscribe(payload => {
|
||||
process.chdir(startingDir);
|
||||
callback(payload);
|
||||
delete Elm;
|
||||
});
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ const generateRecords = require("./generate-records.js");
|
||||
const contentGlobPath = "content/**/*.emu";
|
||||
|
||||
let watcher = null;
|
||||
let devServerRunning = false;
|
||||
|
||||
function unpackFile(path) {
|
||||
return { path, contents: fs.readFileSync(path).toString() };
|
||||
@ -67,12 +68,15 @@ function run() {
|
||||
doCliStuff(staticRoutes, contents.rawContent, function(manifestConfig) {
|
||||
if (contents.watch) {
|
||||
startWatchIfNeeded();
|
||||
develop.start({
|
||||
routes: contents.routes,
|
||||
debug: contents.debug,
|
||||
fileContents: contents.fileContents,
|
||||
manifestConfig
|
||||
});
|
||||
if (!devServerRunning) {
|
||||
devServerRunning = true;
|
||||
develop.start({
|
||||
routes: contents.routes,
|
||||
debug: contents.debug,
|
||||
fileContents: contents.fileContents,
|
||||
manifestConfig
|
||||
});
|
||||
}
|
||||
} else {
|
||||
develop.run(
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user