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
This commit is contained in:
Noah Klayman 2019-12-19 10:08:36 -08:00 committed by Lucas Fernandes Nogueira
parent 48b79534da
commit cb37da454e
1 changed files with 7 additions and 2 deletions

View File

@ -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 {