Give an error if elm-review isn't found on the PATH.

This commit is contained in:
Dillon Kearns 2021-08-27 10:59:35 -07:00
parent 87b60e4856
commit f40e1d0db2
2 changed files with 25 additions and 0 deletions

View File

@ -47,6 +47,11 @@ async function ensureRequiredExecutables() {
} catch (error) { } catch (error) {
throw "I couldn't find elm-optimize-level-2 on the PATH. Please ensure it's installed, either globally, or locally. If it's installed locally, ensure you're running through an NPM script or with npx so the PATH is configured to include it."; throw "I couldn't find elm-optimize-level-2 on the PATH. Please ensure it's installed, either globally, or locally. If it's installed locally, ensure you're running through an NPM script or with npx so the PATH is configured to include it.";
} }
try {
await which("elm-review");
} catch (error) {
throw "I couldn't find elm-review on the PATH. Please ensure it's installed, either globally, or locally. If it's installed locally, ensure you're running through an NPM script or with npx so the PATH is configured to include it.";
}
} }
async function run(options) { async function run(options) {

View File

@ -1,5 +1,6 @@
const path = require("path"); const path = require("path");
const fs = require("fs"); const fs = require("fs");
const which = require("which");
const chokidar = require("chokidar"); const chokidar = require("chokidar");
const { const {
spawnElmMake, spawnElmMake,
@ -49,6 +50,12 @@ async function start(options) {
}); });
await codegen.generate(options.base); await codegen.generate(options.base);
try {
await ensureRequiredExecutables();
} catch (error) {
console.error(error);
process.exit(1);
}
let clientElmMakeProcess = compileElmForBrowser(); let clientElmMakeProcess = compileElmForBrowser();
let pendingCliCompile = compileCliApp(); let pendingCliCompile = compileCliApp();
watchElmSourceDirs(true); watchElmSourceDirs(true);
@ -521,4 +528,17 @@ function errorHtml() {
`; `;
} }
async function ensureRequiredExecutables() {
try {
await which("elm");
} catch (error) {
throw "I couldn't find elm on the PATH. Please ensure it's installed, either globally, or locally. If it's installed locally, ensure you're running through an NPM script or with npx so the PATH is configured to include it.";
}
try {
await which("elm-review");
} catch (error) {
throw "I couldn't find elm-review on the PATH. Please ensure it's installed, either globally, or locally. If it's installed locally, ensure you're running through an NPM script or with npx so the PATH is configured to include it.";
}
}
module.exports = { start }; module.exports = { start };