2019-08-20 01:20:20 +03:00
|
|
|
const fs = require("fs");
|
|
|
|
const runElm = require("./compile-elm.js");
|
|
|
|
const copyModifiedElmJson = require("./rewrite-elm-json.js");
|
2019-08-20 02:25:30 +03:00
|
|
|
const { elmPagesCliFile } = require("./elm-file-constants.js");
|
2019-08-20 01:20:20 +03:00
|
|
|
|
2019-08-20 01:58:55 +03:00
|
|
|
module.exports = function run(rawContentFile, callback) {
|
2019-08-20 01:20:20 +03:00
|
|
|
// mkdir -p elm-stuff/elm-pages/
|
|
|
|
// requires NodeJS >= 10.12.0
|
|
|
|
fs.mkdirSync("./elm-stuff/elm-pages", { recursive: true });
|
|
|
|
|
|
|
|
// write `PagesNew.elm` with cli interface
|
|
|
|
fs.writeFileSync("./elm-stuff/elm-pages/PagesNew.elm", elmPagesCliFile);
|
|
|
|
|
|
|
|
// generate RawContent.elm
|
2019-08-20 01:58:55 +03:00
|
|
|
fs.writeFileSync("./elm-stuff/elm-pages/RawContent.elm", rawContentFile);
|
2019-08-20 01:20:20 +03:00
|
|
|
|
|
|
|
// write modified elm.json to elm-stuff/elm-pages/
|
|
|
|
copyModifiedElmJson();
|
|
|
|
|
|
|
|
// run Main.elm from elm-stuff/elm-pages with `runElm`
|
2019-08-20 01:58:55 +03:00
|
|
|
runElm(callback);
|
2019-08-20 01:20:20 +03:00
|
|
|
};
|