feat(tauri.js/tauri-config): throw error if req'd files don't ex… (#137)

* feat(tauri.js/tauri-config): throw error if req'd files don't exist
Checks that package.json and tauri.conf.js exist before requiring
If they don't, throw an error and exit w/ code 1

* fix(tauri.js/tauri-config): use logger
This commit is contained in:
Noah Klayman 2019-12-06 03:44:29 -08:00 committed by Lucas Fernandes Nogueira
parent ae51d9573e
commit b076dd4d23
1 changed files with 16 additions and 2 deletions

View File

@ -1,8 +1,22 @@
const appPaths = require('./app-paths')
const merge = require('webpack-merge')
const error = require('../helpers/logger')('ERROR:', 'red')
const { existsSync } = require('fs-extra')
module.exports = cfg => {
const tauriConf = require(appPaths.resolve.app('tauri.conf.js'))(cfg.ctx)
const pkgPath = appPaths.resolve.app('package.json')
const tauriConfPath = appPaths.resolve.app('tauri.conf.js')
if (!existsSync(pkgPath)) {
error('Could not find a package.json in your app\'s directory.')
process.exit(1)
}
if (!existsSync(tauriConfPath)) {
error('Could not find a tauri config (tauri.conf.js) in your app\'s directory.')
process.exit(1)
}
const tauriConf = require(tauriConfPath)(cfg.ctx)
const pkg = require(pkgPath)
const config = merge({
build: {
distDir: './dist'
@ -19,7 +33,7 @@ module.exports = cfg => {
all: false
},
window: {
title: require(appPaths.resolve.app('package.json')).productName
title: pkg.productName
},
security: {
csp: 'default-src data: filesystem: ws: http: https: \'unsafe-eval\' \'unsafe-inline\''