From cb37da454e4e743ce01b20f0828a574295b430a2 Mon Sep 17 00:00:00 2001 From: Noah Klayman Date: Thu, 19 Dec 2019 10:08:36 -0800 Subject: [PATCH] feat(runner/build): add error message for missing dist (#185) If distDir/index.html cannot be found, print a helpful error message Previously, a TypeError woud occur --- cli/tauri.js/runner.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cli/tauri.js/runner.js b/cli/tauri.js/runner.js index f5269a420..149ad10c3 100644 --- a/cli/tauri.js/runner.js +++ b/cli/tauri.js/runner.js @@ -2,7 +2,7 @@ const chokidar = require('chokidar') const debounce = require('lodash.debounce') const path = require('path') -const { readFileSync, writeFileSync } = require('fs-extra') +const { readFileSync, writeFileSync, existsSync } = require('fs-extra') const { spawn } = require('./helpers/spawn') @@ -134,7 +134,12 @@ class Runner { const inlinedAssets = [] return new Promise((resolve, reject) => { - new Inliner(path.join(indexDir, 'index.html'), (err, html) => { + const distIndexPath = path.join(indexDir, 'index.html') + if (!existsSync(distIndexPath)) { + warn(`Error: cannot find index.html in "${indexDir}". Did you forget to build your web code or update the build.distDir in tauri.conf.js?`) + reject(new Error('Could not find index.html in dist dir.')) + } + new Inliner(distIndexPath, (err, html) => { if (err) { reject(err) } else {