From f1070d140355a6014bb1bfafa92578c4cb9476e2 Mon Sep 17 00:00:00 2001 From: Chris Berthe Date: Wed, 10 May 2017 18:35:24 -0400 Subject: [PATCH] Remove error thrown when running slate build (#59) --- src/tasks/build-config.js | 6 ------ src/tasks/deploy-utils.js | 18 +++++++++++++++--- src/tasks/includes/messages.js | 4 +++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/tasks/build-config.js b/src/tasks/build-config.js index 39e2789f..9aaac30b 100644 --- a/src/tasks/build-config.js +++ b/src/tasks/build-config.js @@ -1,5 +1,4 @@ const gulp = require('gulp'); -const fs = require('fs'); const plumber = require('gulp-plumber'); const size = require('gulp-size'); const chokidar = require('chokidar'); @@ -11,11 +10,6 @@ const messages = require('./includes/messages.js'); function processConfig(file) { messages.logProcessFiles('build:config'); - // eslint-disable-next-line no-sync, node/no-deprecated-api - if (!fs.existsSync(file)) { - throw new Error(messages.configError()); - } - return gulp.src(file) .pipe(plumber(utils.errorHandler)) .pipe(size({ diff --git a/src/tasks/deploy-utils.js b/src/tasks/deploy-utils.js index bbb076a4..f4d347a9 100644 --- a/src/tasks/deploy-utils.js +++ b/src/tasks/deploy-utils.js @@ -66,9 +66,22 @@ function validateId(settings) { * @memberof slate-cli.tasks.watch, slate-cli.tasks.deploy * @private */ - gulp.task('validate:id', () => { - const file = fs.readFileSync(config.tkConfig, 'utf8'); + let file; + + try { + file = fs.readFileSync(config.tkConfig, 'utf8'); + } catch (err) { + if (err.code !== 'ENOENT') { + throw new Error(err); + } + + messages.configError(); + + const exitCode = 2; + return process.exit(exitCode); + } + const tkConfig = yaml.safeLoad(file); let envObj; @@ -95,7 +108,6 @@ gulp.task('validate:id', () => { const exitCode = 2; return process.exit(exitCode); }); - }); /** diff --git a/src/tasks/includes/messages.js b/src/tasks/includes/messages.js index fc65aa05..2e7b4432 100644 --- a/src/tasks/includes/messages.js +++ b/src/tasks/includes/messages.js @@ -81,7 +81,9 @@ const messages = { }, configError: () => { - return '`config.yml` does not exist. You need to add a config file before you can upload your theme to Shopify.'; + gutil.log('File missing:', + gutil.colors.yellow('`config.yml` does not exist. You need to add a config file before you can make changes to your Shopify store.'), + ); }, deployTo: (environment) => {