From b076dd4d23d4e119adfa5fa419b5e440d6088b3e Mon Sep 17 00:00:00 2001 From: Noah Klayman Date: Fri, 6 Dec 2019 03:44:29 -0800 Subject: [PATCH] =?UTF-8?q?feat(tauri.js/tauri-config):=20throw=20error=20?= =?UTF-8?q?if=20req'd=20files=20don't=20ex=E2=80=A6=20(#137)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- cli/tauri.js/helpers/tauri-config.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cli/tauri.js/helpers/tauri-config.js b/cli/tauri.js/helpers/tauri-config.js index 05fc94664..c8d7812fa 100644 --- a/cli/tauri.js/helpers/tauri-config.js +++ b/cli/tauri.js/helpers/tauri-config.js @@ -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\''