From 7a172e7c300cc07529024cbbed9b70089d58b917 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Thu, 18 May 2017 15:15:25 +0100 Subject: [PATCH] Remove old way of specifying demos using javascript. (#452) --- lib/tasks/demo.js | 12 ++++++++++-- test/tasks/demo.test.js | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/tasks/demo.js b/lib/tasks/demo.js index 3c807720..937373ec 100644 --- a/lib/tasks/demo.js +++ b/lib/tasks/demo.js @@ -259,7 +259,6 @@ module.exports = function(gulp, config) { // can keep on compiling demos of older versions of modules let configPaths = [ 'demos/src/config.json', - 'demos/src/config.js', 'origami.json' ]; let configPath; @@ -281,7 +280,16 @@ module.exports = function(gulp, config) { if (configPath) { log.primary('Building' + (config.dist ? ' build service' : ' local') + ' demos (config: ' + configPath + ')'); - const demosConfig = require(configPath); + let demosConfig; + + try { + demosConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8')); + } catch (error) { + const demoConfigError = `${configPath} is not valid JSON.`; + const demoConfigErrorStream = errorStream(demoStream, demoConfigError); + return demoConfigErrorStream; + } + const demos = []; builtFiles.css = []; builtFiles.js = []; diff --git a/test/tasks/demo.test.js b/test/tasks/demo.test.js index 03fb74ec..5986d814 100644 --- a/test/tasks/demo.test.js +++ b/test/tasks/demo.test.js @@ -1,4 +1,4 @@ -/* global describe, it, before, after */ +/* eslint-env mocha */ 'use strict'; const expect = require('expect.js'); @@ -43,7 +43,7 @@ describe('Demo task', function() { fs.writeFileSync('bower.json', '{"name":"o-test"}', 'utf8'); demo(gulp) .on('error', function(err) { - expect(err.message).to.be('Couldn\'t find demos config path, checked: origami.json,demos/src/config.js,demos/src/config.json'); + expect(err.message).to.be('Couldn\'t find demos config path, checked: origami.json,demos/src/config.json'); fs.unlink(path.resolve(obtPath, 'bower.json')); process.chdir(demoTestPath); done();